There are 27 linting rules available in eslint-plugin-testing-library, here’s a summary of the linting rules picked for our web register
To reduce flaky tests (that passes when they should)
- Disallow the use of the global RegExp flag (/g) in queries (
testing-library/no-global-regexp-flag-in-query
)
To create effective tests (that fails when they should)
- Enforce promises from async queries to be handled (
testing-library/await-async-query
) - Enforce promises from async utils to be handled (
testing-library/await-async-utils
)
To create more helpful error messages
To best mimic user interaction
- Disallow
container
and its too-powerful methods likequerySelector
(testing-library/no-container
)
To simplify tests
- Prefer
findBy
overwaitFor
+getBy
To use modern approach
- Use
waitFor
instead ofwait
-> deprecation - use
view
,utils
, or destructing forrender
results, instead ofwrapper