not wrapped in act ⚛️ React

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.

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