Testing · Junior · Question 55 of 78
How do you check the result of clicking a counter button?
const user = userEvent.setup();
render(<Counter />);
await user.click(screen.getByRole("button", { name: "+" }));- ✓Correct answer:
expect(screen.getByText("Count: 1")).toBeInTheDocument() - 2
expect(Counter.state.count).toBe(1) - 3
expect(useState).toHaveBeenCalledWith(1)
Explanation
Check what the user sees, not the component's internal state.