Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 1.15 KB

File metadata and controls

34 lines (22 loc) · 1.15 KB

testing-library/no-test-id-queries

📝 Ensure no data-testid queries are used.

Rule Details

This rule aims to reduce the usage of *ByTestId queries in your tests.

When using *ByTestId queries, you are coupling your tests to the implementation details of your components, and not to how they behave and being used.

Prefer using queries that are more related to the user experience, like getByRole, getByLabelText, etc.

Example of incorrect code for this rule:

const button = queryByTestId('my-button');
const input = screen.queryByTestId('my-input');

Examples of correct code for this rule:

const button = screen.getByRole('button');
const input = screen.getByRole('textbox');

Further Reading