Command Palette

Search for a command to run...

Hectal
Phase 17: Testing React
React · Exercise 1 of 5Next
Beginner

Your first two tests

The code has a Greeting component and the little test() / expect() helper used in this phase's examples.

Write two tests with the helper. The first renders <Greeting name="Asha" /> and checks that the heading's text is exactly Hello, Asha!. The second does the same for Ravi (Hello, Ravi!).

Find the heading with screen.getByRole("heading"), not with querySelector.

Both tests must print a ✓ line in the console and none may print ✗.

What Check tests

  1. At least two tests pass (two ✓ lines in the console)
  2. No test fails
  3. The heading is found with getByRole
  4. One test checks Ravi's greeting
  5. A greeting is on the page

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.