Advanced
Test loading, errors and retry
Quote({ loadQuote }) is finished and works. Your job is to write the tests, using fake loadQuote functions you create.
Write at least three tests: (1) it shows Loading quote... first and then the quote text; (2) when loadQuote rejects with an error, an alert shows the error message; (3) after a failure, clicking Try again loads and shows the quote (make a fake that fails the first time and succeeds the second).
Use findBy... queries to wait for things that appear later, and userEvent to click. Keep your fakes fast (100–300 ms). Every test must print ✓.
What Check tests
- At least three tests pass
- No test fails
- Uses findBy queries to wait
- Has a fake that fails (rejects)
- Clicks Try again with user-event
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.