Installations
npm install eslint-plugin-jest-dom
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
^12.22.0 || ^14.17.0 || >=16.0.0
Node Version
16.20.2
NPM Version
8.19.4
Score
93.2
Supply Chain
93.4
Quality
78.4
Maintenance
100
Vulnerability
98.9
License
Releases
Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
testing-library
Download Statistics
Total Downloads
153,386,591
Last Day
238,602
Last Week
1,231,557
Last Month
5,137,773
Last Year
53,890,235
GitHub Statistics
MIT License
364 Stars
187 Commits
41 Forks
8 Watchers
8 Branches
44 Contributors
Updated on Feb 13, 2025
Bundle Size
4.78 kB
Minified
1.88 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.5.0
Package Id
eslint-plugin-jest-dom@5.5.0
Unpacked Size
85.06 kB
Size
15.15 kB
File Count
20
NPM Version
8.19.4
Node Version
16.20.2
Published on
Nov 17, 2024
Total Downloads
Cumulative downloads
Total Downloads
153,386,591
Last Day
1.1%
238,602
Compared to previous day
Last Week
2.9%
1,231,557
Compared to previous week
Last Month
55.6%
5,137,773
Compared to previous month
Last Year
19%
53,890,235
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
eslint-plugin-jest-dom
ESLint plugin to follow best practices and anticipate common mistakes when writing tests with jest-dom.
Table of Contents
Installation
This module is distributed via npm which is bundled with node and
should be installed as one of your project's devDependencies
:
npm install --save-dev eslint-plugin-jest-dom
This library has a required peerDependencies
listing for ESLint
.
Usage
[!NOTE]
eslint.config.js
is supported, though most of the plugin documentation still currently uses.eslintrc
syntax; compatible versions of configs are available prefixed withflat/
and may be subject to small breaking changes while ESLint v9 is being finalized.Refer to the ESLint documentation on the new configuration file format for more.
Add jest-dom
to the plugins section of your .eslintrc.js
configuration file.
You can omit the eslint-plugin-
prefix:
1module.exports = { 2 plugins: ["jest-dom"], 3 rules: { 4 // your configuration 5 }, 6};
Then configure the rules you want to use under the rules section.
1module.exports = { 2 rules: { 3 "jest-dom/prefer-checked": "error", 4 "jest-dom/prefer-enabled-disabled": "error", 5 "jest-dom/prefer-required": "error", 6 "jest-dom/prefer-to-have-attribute": "error", 7 }, 8};
Recommended Configuration
This plugin exports a recommended configuration that enforces good jest-dom
practices (you can find more info about enabled rules in
Supported Rules section).
To enable this configuration with .eslintrc
, use the extends
property:
1module.exports = { 2 extends: "plugin:jest-dom/recommended", 3 rules: { 4 // your configuration 5 }, 6};
To enable this configuration with eslint.config.js
, use
jestDom.configs['flat/recommended']
:
1module.exports = [ 2 { 3 files: [ 4 /* glob matching your test files */ 5 ], 6 ...require("eslint-plugin-jest-dom").configs["flat/recommended"], 7 }, 8];
Supported Rules
💼 Configurations enabled in.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the --fix
CLI option.
💡 Manually fixable by editor suggestions.
Name | Description | 💼 | 🔧 | 💡 |
---|---|---|---|---|
prefer-checked | prefer toBeChecked over checking attributes | ✅ | 🔧 | |
prefer-empty | Prefer toBeEmpty over checking innerHTML | ✅ | 🔧 | |
prefer-enabled-disabled | prefer toBeDisabled or toBeEnabled over checking attributes | ✅ | 🔧 | |
prefer-focus | prefer toHaveFocus over checking document.activeElement | ✅ | 🔧 | |
prefer-in-document | Prefer .toBeInTheDocument() for asserting the existence of a DOM node | ✅ | 🔧 | 💡 |
prefer-required | prefer toBeRequired over checking properties | ✅ | 🔧 | |
prefer-to-have-attribute | prefer toHaveAttribute over checking getAttribute/hasAttribute | ✅ | 🔧 | |
prefer-to-have-class | prefer toHaveClass over checking element className | ✅ | 🔧 | |
prefer-to-have-style | prefer toHaveStyle over checking element style | ✅ | 🔧 | |
prefer-to-have-text-content | Prefer toHaveTextContent over checking element.textContent | ✅ | 🔧 | |
prefer-to-have-value | prefer toHaveValue over checking element.value | ✅ | 🔧 |
Issues
Looking to contribute? Look for the Good First Issue label.
🐛 Bugs
Please file an issue for bugs, missing documentation, or unexpected behavior.
💡 Feature Requests
Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.
Contributors ✨
Thanks goes to these people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
LICENSE
MIT

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
2 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 8/23 approved changesets -- score normalized to 3
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/smoke-test.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/smoke-test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/smoke-test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/smoke-test.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/smoke-test.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/smoke-test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:95: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:98: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/validate.yml:103: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/validate.yml:113: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/validate.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/validate.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/eslint-plugin-jest-dom/validate.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/smoke-test.yml:17
- Warn: npmCommand not pinned by hash: .github/workflows/validate.yml:64
- Warn: npmCommand not pinned by hash: .github/workflows/validate.yml:67
- Warn: npmCommand not pinned by hash: .github/workflows/validate.yml:71
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 5 third-party GitHubAction dependencies pinned
- Info: 0 out of 4 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/smoke-test.yml:1
- Warn: no topLevel permission defined: .github/workflows/validate.yml:1
- Info: no jobLevel write permissions found
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 29 are checked with a SAST tool
Score
4.4
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to eslint-plugin-jest-dom
@anolilab/eslint-config
ESLint shareable config for the Anolilab JavaScript style guide.
@teamteanpm2024/saepe-alias-perferendis
<div align="center"> <h1>jest-dom</h1>
@diotoborg/laboriosam-aut
<div align="center"> <a href="https://eslint.org/"> <img height="150" src="https://eslint.org/assets/images/logo/eslint-logo-color.svg"> </a> <a href="https://jestjs.io/"> <img width="150" height="150" vspace="" hspace="25" src="https://jest
@diotoborg/a-odio
<h1 align="center">typescript-eslint</h1>