Test Effects Generated from React the useEffect Hook

InstructorKent C. Dodds

Share this video with your friends

Send Tweet

NOTE: React Suspense for data fetching is VERY ALPHA and this API is undocumented, unsupported, and will likely change.

Our Counter component has grown in complexity and we need to figure out how to get it tested. In this lesson, we'll learn how to test the effects that are generated with useEffect.

We'll cover:

  • How React schedules callbacks after the component renders
  • Keeping our tests isolated with afterEach
~ 2 years ago

awesome tests!

Shawn Mitchell
~ 2 years ago

Looks like you added 3 expects but your test output only show 2 test passing?

House Developer
~ 2 years ago

Hi Kent. Great videos, thanks! When I watched this the first time it was part of a playlist covering a lot of nice things regarding hooks and suspense, but now I can't find the playlist anymore… What happened?

Kent C. Doddsinstructor
~ 2 years ago

Tomeu, thanks!

Shawn, the output only shows one test for each call of test. You can have multiple expects in a single test.

House, thanks! You can find the full playlist here: http://kcd.im/hooks-and-suspense

Egghead's working on making playlists surface better in the UI.