You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On jest, afterEach(cleanup) is too late to unmount a component using useSyncExternalStore with asynchronous updating #1421
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(...)..
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.
Activity
beanscg commentedon Jun 9, 2026