@testing-library/react version: 16.3.0
react version: 19.2.0
- Testing Framework and version:
- DOM Environment:
Relevant code or config:
None (please see reproduction repository described below)
What you did:
Testing a component using React's useSyncExternalStore and running the test without async
What happened:
useSyncExternalStore's update may happen just after finishing the test, but afterEach is not called in that timing, so the callback of useSyncExternalStore cannot handle 'unmounted' state, resulting the log An update to TestComponent inside a test was not wrapped in act(...)..
Reproduction:
I created a repositoy for the reproduction: https://github.com/jet2jet/testing-test
Problem description:
During just after finishing a test and just before afterEach, the test code cannot insert act() calls, so the problem An update to ... cannot be resolved with using act().
Suggested solution:
I think it's very difficult to call cleanup() just after finishing a test, but it's necessary to unmount, for resolving timing problem.
@testing-library/reactversion: 16.3.0reactversion: 19.2.0jest: 30.2.0jsdom: 27.0.1Relevant code or config:
None (please see reproduction repository described below)
What you did:
Testing a component using React's
useSyncExternalStoreand running the test withoutasyncWhat happened:
useSyncExternalStore's update may happen just after finishing the test, butafterEachis not called in that timing, so the callback ofuseSyncExternalStorecannot handle 'unmounted' state, resulting the logAn update to TestComponent inside a test was not wrapped in act(...)..Reproduction:
I created a repositoy for the reproduction: https://github.com/jet2jet/testing-test
Problem description:
During just after finishing a test and just before
afterEach, the test code cannot insertact()calls, so the problemAn update to ...cannot be resolved with usingact().Suggested solution:
I think it's very difficult to call
cleanup()just after finishing a test, but it's necessary to unmount, for resolving timing problem.