Course lesson

Get Rid of the "not wrapped in act(...)" Warning

For many years, the most annoying thing about writing tests with the React Testing Library is when the "not wrapped in act(...)" warning appears in your console. act is a React testing util that ensures all UI updates are wrapped up before proceeding with...

Duration
2 min
Access
Included
Transcript
Retained from source evidence

For many years, the most annoying thing about writing tests with the React Testing Library is when the "not wrapped in act(...)" warning appears in your console. act is a React testing util that ensures all UI updates are wrapped up before proceeding with your test case. What we often miss is that we actually don't need act and that this error is there to tell us something instead, and that is: You are not testing everything!

In this lesson, we are going to understand why the "not wrapped in act(...)" shows up and how to get rid of it!