Fix the "not wrapped in act(...)" warning when testing Custom Hooks

Kent C. Dodds
InstructorKent C. Dodds

Share this video with your friends

Send Tweet

Any time your test interacts with a React component in a way that results in a state update, you need to make sure you wrap that interaction in an act function call, otherwise you'll get the "not wrapped in act(...)" warning.

In this lesson you'll learn how you can use act with @testing-library/react-hooks to avoid potential bugs in your custom React hooks.

This is based on my blog post: Fix the "not wrapped in act(...)" warning