Challenge: Fix this async click behaviour test

I would say one of the areas that causes the most amount of minor bugs in React testing code is when dealing with async behaviour. Little subtle bugs can creep in, and you end up testing the wrong values, wrong elements, or not waiting for state to fully update.

In this test challenge there is a bug in the test, which is why the test is failing. Can you spot it?

i
Challenge Mode: This lesson is actually a challenge - you are given a half working test and have to figure out how to get it working correctly.

You can use our courses to learn how to solve this challenge - there are courses on everything from basic Jest/Vitest fundamentals, down to how to test frontend code (using React Testing Library).

Loading full lesson content & code...

Ready to try running tests for this lesson?