Challenge: Async expect().resolves bug

One of the worst things to do in a test is have false positives or false negatives.

Sometimes (especially with async behaviour) it is possible to accidentally write tests in a way that they never fail (or, always pass!).

In this test challenge there is a simple async function to test. It should be obvious what this function is doing.

However in this test challenge the test assertions are incorrectly marking the test as passing!

This is the sort of bug that is either immediately obvious (you might have spotted it within a few seconds), or becomes a complete pain to debug until you finally find it (then it will be obvious!)

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?