Skip to content

Glossary: Testing Web Apps

getBy

Also written: getByRole, getByLabelText, getByText, getByTestId, data-testid

A form of Testing Library query that finds an element or throws and fails the test. Use it for things that should be there now; `getByTestId` (an element's hidden `data-testid`) is the last resort.

Where the book teaches it

Related terms

queryByfindByQueryRole