ESLint plugin to enforce best practices and prevent common mistakes when writing tests with jest-dom.
eslint-plugin-jest-dom is an ESLint plugin that provides linting rules specifically for tests written with jest-dom. It helps developers write better, more consistent tests by enforcing best practices and catching common mistakes in jest-dom assertions. The plugin automatically suggests improvements to make tests more readable and maintainable.
Frontend developers and test engineers who use jest-dom with Jest or Testing Library for DOM testing in JavaScript/TypeScript projects. It's particularly valuable for teams wanting to maintain high-quality test suites with consistent patterns.
Developers choose this plugin because it provides automated guidance specifically for jest-dom patterns, reducing manual code review burden and preventing subtle testing bugs. It integrates seamlessly with ESLint workflows and offers both recommended configurations and customizable rules.
eslint rules for use with jest-dom
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 jest-dom's user-centric testing philosophy by automatically suggesting matchers like `toBeChecked()` and `toBeEmpty()`, reducing manual assertion errors, as shown in the supported rules list.
Offers a recommended configuration that can be extended in ESLint settings, making setup straightforward without enabling each rule individually, documented in the Recommended Configuration section.
Most rules are fixable with ESLint's --fix option, allowing quick correction of violations, as indicated by the 🔧 icon in the rules table, saving time during refactoring.
Covers all major jest-dom assertion types from checked states to style checks, with 11 supported rules ensuring consistent test patterns across the codebase.
Only valuable if using jest-dom; provides no support for other DOM testing libraries like Enzyme or vanilla Jest, limiting its utility in mixed or transitioning codebases.
The README notes that documentation for ESLint v9's new config format is still catching up, with potential breaking changes, which can confuse users adopting modern setups.
Does not allow creation of custom rules, so teams with unique testing patterns cannot extend the plugin beyond the predefined set, reducing flexibility.
Requires ESLint as a peer dependency, which might lead to version conflicts or additional setup steps, as mentioned in the installation instructions.