Course lesson

Get Elements With an Associated Test id Attribute Using the byTestId Query

Sometimes, none of the queries above will work for you. Instead of focusing on implementation details, the React Testing Library gives you a controlled way of doing so: using data-testid!

Duration
1 min
Access
Included
Transcript
Needs source

Sometimes, none of the queries above will work for you. Instead of focusing on implementation details, the React Testing Library gives you a controlled way of doing so: using data-testid!

In this lesson, we are going to look at the one query that belongs to the TestId family and should be used as a last resort only: the byTestId query.