Challenge: fix the spy problem!

Sometimes when dealing with tests, it is easy to make a mistake and one test affects another one.

In this test challenge we have exactly that... there are two tests. The first passes fine. The second would pass fine if the first one wasn't there.

The reason in this case is because the .spyOn() sets it up so the unit under test throws an error. But this behaviour is not expected in the second test.

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?