Warning: An update to Component inside a test was not wrapped in act(...)
A component updated state after the test’s synchronous assertions — async work wasn’t awaited.
was not wrapped in act(...)inside a test was not wrapped in act Meaning
Testing Library wraps render and events in act, but async effects (fetches, timers) resolve later. Await the UI changes with findBy*/waitFor.
Common causes
- Assertions before async data loads
- Unawaited timers or promises
- Tests ending while effects still run
⚡ Quick fix
- Use await screen.findByText(...) or await waitFor(...)
- Use fake timers and advance them inside act
- Mock async dependencies
Detailed fix by platform
React
expect(await screen.findByText('Loaded')).toBeInTheDocument();
How to diagnose
- Update — Which async work triggers it?
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- AbortError AbortError: The user aborted a request. / signal is aborted without reason
- async useEffect Warning: useEffect must not return anything besides a function, which is used for clean-up. It looks like you wrote useEffect(async () => ...)
- await outside async SyntaxError: await is only valid in async functions and the top level bodies of modules
Most viewed in React
- React must be in scope ReferenceError: React is not defined / 'React' must be in scope when using JSX
- Objects are not valid as a React child Error: Objects are not valid as a React child
- Functions cannot be passed Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 12 Oct 2026