React Testing Library has methods for several types of queries. There are six query method variants:
getBy*()
- returns the first matching element and throws when an element not found or more than one element found;queryBy*()
- returns the first matching element but doesn’t throw;findBy*()
- returns a promise that resolves with a matching element, or rejects when an element not found after a default timeout or more than one element found;getAllBy*()
,queryAllBy*()
,findAllBy*()
: same as above but return all found elements, not just the first one.
And the queries are: