ESLint plugin to enforce best practices and prevent common mistakes when writing tests with Testing Library.
eslint-plugin-testing-library is an ESLint plugin that enforces best practices and prevents common mistakes when writing tests with the Testing Library ecosystem. It helps developers avoid anti-patterns, ensures proper async handling, and promotes user-centric testing approaches. The plugin integrates seamlessly with popular frameworks like React, Vue, Angular, and Svelte through shareable configurations.
Frontend developers and test engineers using Testing Library with frameworks like React, Vue, Angular, Svelte, or Marko. It's particularly valuable for teams aiming to maintain consistent, high-quality test suites across projects.
Developers choose this plugin because it automatically enforces Testing Library's core principles, reduces flaky tests, and catches errors early. Its framework-specific configurations and auto-fixable rules save time and ensure tests are both effective and maintainable.
ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enforces proper await usage for async queries, events, and utilities to prevent race conditions, as detailed in rules like await-async-queries and await-async-events from the supported rules list.
Detects and discourages common mistakes like direct DOM node access, unnecessary awaits on sync queries, and misuse of container methods, promoting cleaner test code aligned with Testing Library philosophy.
Provides shareable, pre-configured rulesets for popular Testing Library integrations (React, Vue, Angular, etc.), simplifying setup for different frameworks, as shown in the usage section with extendable configs.
Many rules support ESLint's --fix flag for automatic code fixes, streamlining corrections and reducing manual effort, highlighted by the 🔧 icon in the supported rules table.
Frequent major updates require migration efforts, as evidenced by separate migration guides for v4 through v7, which can disrupt workflows and add maintenance overhead.
Only valuable for projects using Testing Library; it offers no benefits for other testing approaches like Enzyme or Vitest's built-in utilities, making it a niche tool.
Setting up ESLint overrides or separate configs to run only on test files adds initial setup complexity, as detailed in the 'Run the plugin only against test files' section, which can be error-prone.