💼 This rule is enabled in the following configs: angular
, dom
, marko
, react
, vue
.
🔧 This rule is automatically fixable by the --fix
CLI option.
Ensure that sync queries are not awaited unnecessarily.
Usual queries variants that Testing Library provides are synchronous and don't need to wait for any element. Those queries are:
getBy*
getByAll*
queryBy*
queryAllBy*
This rule aims to prevent users from waiting for synchronous queries.
Examples of incorrect code for this rule:
const foo = async () => {
// ...
const rows = await queryAllByRole('row');
// ...
};
const bar = () => {
// ...
getByText('submit').then(() => {
// ...
});
};
const baz = () => {
// ...
const button = await screen.getByText('submit');
};
Examples of correct code for this rule:
const foo = () => {
// ...
const rows = queryAllByRole('row');
// ...
};
const bar = () => {
// ...
const button = getByText('submit');
// ...
};
const baz = () => {
// ...
const button = screen.getByText('submit');
};