not wrapped in act React Origin: On your device OSI layer 7 · Application Last updated 12 Oct 2026

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.

Exact message you may see was not wrapped in act(...)inside a test was not wrapped in act
Seen on: React

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

  1. Use await screen.findByText(...) or await waitFor(...)
  2. Use fake timers and advance them inside act
  3. Mock async dependencies

Detailed fix by platform

React

  1. expect(await screen.findByText('Loaded')).toBeInTheDocument();

How to diagnose

  1. Update — Which async work triggers it?
  2. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

AbortError — AbortError: The user aborted a request. / signal is aborted without reason (JavaScript)AbortErrorasync useEffect — Warning: useEffect must not return anything besides a function, which is used for clean-up. It looks like you wrote useEffect(async () => ...) (React)async useEffectawait outside async — SyntaxError: await is only valid in async functions and the top level bodies of modules (JavaScript)await outside asyncbody already used — TypeError: Failed to execute 'json' on 'Response': body stream already read (JavaScript)body already usedCould not Fast Refresh — [vite] hmr invalidate … Could not Fast Refresh. Export is incompatible. (React)Could not Fast RefreshEvent loop is closed — RuntimeError: Event loop is closed (Python)Event loop is closedJest ESM — Jest: SyntaxError: Cannot use import statement outside a module (Jest encountered an unexpected token) (React)Jest ESMkey is not a prop — Warning: `key` is not a prop. Trying to access it will result in `undefined` being returned. (React)key is not a propnot wrapp…

Explore the map of this error Full error map →

🧠 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.