Skip to content

How to fix warning An update to TimerRoot inside a test was not wrapped in act(...) with timers? #1348

Open
@blasdfaa

Description

@blasdfaa

tests are running correctly, but a warning appears in console. How can I fix this?

Warning: An update to TimerRoot inside a test was not wrapped in act(...).

When testing, code that causes React state updates should be wrapped into act(...):

act(() => {
  /* fire events that update state */
});
/* assert on the output */

Demo - https://stackblitz.com/edit/vitejs-vite-7zbv1rkb?file=src%2FApp.test.tsx
Run npm run test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions