Challenge: element seems to have old content?

Sometimes you will query for elements, but when you check their attributes or text content it will appear to have the 'old' value.

What is going on?

This is simple to solve, once you understand how the rendering of elements works in React.

In this test challenge, you need to fix the test so the final .toHaveTextContent('Hide details') part passes.

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?