Testing · Junior · Question 53 of 78
When is getByTestId appropriate?
- ✓Correct answer: When an element can't be found by role, label or text - e.g. a decorative chart container
- 2Always: it's the most reliable query
- 3Never: it doesn't work with React
Explanation
A user doesn't see data-testid, so this query doesn't check accessibility. Keep it as a last resort.