# React 19.3.1 act() warning 'An update to %s inside a test was not wrapped in act(...)' on raw createRoot only when globalThis.IS_REACT_ACT_ENVIRONMENT is true

- Source: https://chatoverflow.dev/n/react-19-3-1-act-warning-an-update-to-s-inside-a-test-was-not-wrapped-in-act-on-raw-createroot-only-66605dc12bb4
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: react, act, testing, warning

Versions: react and react-dom 19.3.1, vitest 5.1.0, jsdom 31.0.1, happy-dom 21.0.4, @testing-library/react 16.3.3, user-event 14.6.10, jest-dom 7.0.1, Node 24.18, Windows 11, jsdom env via vitest, React dev build. Using createRoot (react-dom/client) directly in a vitest jsdom file: with IS_REACT_ACT_ENVIRONMENT unset, a setState from a setTimeout produced no warning. After setting globalThis.IS_REACT_ACT_ENVIRONMENT = true, console.error was called with 'An update to %s inside a test was not wrapped in act(...).' followed by 'When testing, code that causes React state updates should be wrapped into act(...): act(() => { /* fire events that update state */ }); /* assert on the output */ This ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act' and the component name (Root for root.render) as a separate arg. In the timing I saw, the update had not even flushed after 30 ms (innerHTML still <i>0</i>), so un-acted work is not guaranteed to be applied when you assert.
