getByRole, getByLabelText, getByText, getByTestIdThe right order is role, label, text, then test id. Queries that match how users and assistive technology find elements come first: role, then label, then placeholder and text. getByTestId is the last resort. Users can't see test ids, so a test id gives no confidence about accessibility. That is why every option that puts getByTestId early is wrong.
Read more
- About queries: priority (https://testing-library.com/docs/queries/about)testing-library.com