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
♻️(refacto) Fix the "not wrapped in act" warnings of the frontend tests #2976
The frontend Vitest suites log many An update to … inside a test was not wrapped in act(...) warnings in the CI: Search.test.tsx (the worst, about 30 blocks), utilsPrint.spec.tsx, LanguagePicker.spec.tsx, useOpenPresenterShortcut.spec.ts, EmojiPicker.test.tsx and UserMentionInlineContent.test.tsx.
They mean a state update lands after the assertions, so a test can pass while the component is not in the state it asserts, and real async bugs get lost in the noise.
Suggested fix: make each test wait for the update (await screen.findBy…, waitFor, or await act(async () => …)), without switching IS_REACT_ACT_ENVIRONMENT off, which only hides them.
Then fail the tests on this warning (spy on console.error in vitest.setup.ts) so it cannot come back.
Run the six suites and note which test logs each warning and which state update it comes from. In Search.test.tsx, most tests use fireEvent and then assert with getBy…, so I expect the docs and users search results to land after the last assertion.
Make each test wait for the update it causes, with await screen.findBy…, waitFor on the final state, or await act(async () => …) where nothing visible changes (the print utility and the shortcut hook). IS_REACT_ACT_ENVIRONMENT stays on.
In vitest.setup.ts, spy on console.error and fail the test when the message contains "not wrapped in act(", leaving other errors alone. Then run the whole frontend suite to check that nothing else trips it.
I'll use AI assistance and say so in the PR, with signed-off commits. Could you assign it to me?
Activity
arxh80 commentedon Nov 5, 2026
Hi, I'd like to take this one.
Plan:
Search.test.tsx, most tests usefireEventand then assert withgetBy…, so I expect the docs and users search results to land after the last assertion.await screen.findBy…,waitForon the final state, orawait act(async () => …)where nothing visible changes (the print utility and the shortcut hook).IS_REACT_ACT_ENVIRONMENTstays on.vitest.setup.ts, spy onconsole.errorand fail the test when the message contains "not wrapped in act(", leaving other errors alone. Then run the whole frontend suite to check that nothing else trips it.I'll use AI assistance and say so in the PR, with signed-off commits. Could you assign it to me?
✅(frontend) fix the act warnings and the noise of the frontend tests
✅(frontend) fix the act warnings and the noise of the frontend tests
✅(frontend) fix the act warnings and the noise of the frontend tests