Skip to content

♻️(refacto) Fix the "not wrapped in act" warnings of the frontend tests #2976

Closed

Description

@AntoLC

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.

Activity

  1. added theissue type on Nov 5, 2026
  2. added
    good first issue
    on Nov 5, 2026
  3. arxh80 commented on Nov 5, 2026

    @arxh80
    Contributor

    Hi, I'd like to take this one.

    Plan:

    1. 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.
    2. 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.
    3. 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?

  4. added 3 commits that reference this issue on Nov 12, 2026
    5096d68
    27bedd1
    f0e1b79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions