-
Couldn't load subscription status.
- Fork 1.1k
Description
@testing-library/reactversion: 16.3.0reactversion: 19.2.0- Testing Framework and version:
jest: 30.2.0
- DOM Environment:
jsdom: 27.0.1
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.