Testing · Middle · Question 25 of 75
How do you find a heading of a specific level?
- ✓Correct answer:
screen.getByRole("heading", { level: 2, name: "Settings" }) - 2
screen.getByText("h2") - 3
screen.getByTag("h2")
Explanation
ByRole supports options like level, checked, pressed, expanded, selected - they check ARIA state too.