Testing · Junior · Question 44 of 78
Which query does Testing Library recommend first?
- ✓Correct answer:
getByRole - 2
getByTestId - 3
container.querySelector
Explanation
Priority: queries accessible to everyone (ByRole, ByLabelText, ByPlaceholderText, ByText, ByDisplayValue), then semantic (ByAltText, ByTitle), and only then ByTestId.