EduFlow
Testing JavaScript Apps

Checkpoint: Testing the UI

Five questions on this section. Answer all of them, then see your score and why each answer is right or wrong.

Question 1 of 5

The form shows validation errors in <p role="alert">Amount must be greater than zero</p>. Which query fits best?

Question 2 of 5

load resolves with { Ben: -500 }. This test fails with “Unable to find an element with the text”. What is the fix?

JSX
test('shows balances', () => {
  render(<BalancePanel loadBalances={load} />);
  expect(screen.getByText('Ben owes $5.00')).toBeInTheDocument();
});
Question 3 of 5

Component tests use MSW with server.listen({ onUnhandledRequest: 'error' }). A refactor accidentally changes the request URL from /groups/:id to /group/:id. What happens?

Question 4 of 5

Which use of waitFor is appropriate?

Question 5 of 5

ExpenseList has a “Hide settled” checkbox. What’s the best test for it?

5 questions unanswered