Challenge: Use a RegExp to find elements

Sometimes selecting the correct element in the DOM can be tricky. If you know Regex (and in the world of LLMs, even if you don't, it is easy to get ChatGPT to generate a Regex for you) then it can sometimes make selecting for a specific element easier.

In this challenge, it is just about remembering how to query for things with a regex.

The regex is provided in the half complete code. Just update the expect(screen.getBy... part.

In other challenges were have more tricky situations where you have to use other techniques to query for those elements.

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?