jest-dom
jest-dom is a library that extends Jest with custom matchers for testing DOM elements, making test assertions clearer and more readable. It lets you write assertions like `.toBeDisabled()` or `.toHaveClass()` instead of verbose DOM inspection logic.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | testing-library/jest-dom |
| Owner | testing-library |
| Primary language | JavaScript |
| License | MIT — OSI-approved |
| Stars | 4.6k |
| Forks | 416 |
| Open issues | 142 |
| Latest release | v6.9.1 (2025-10-01) |
| Last updated | 2026-06-11 |
| Source | https://github.com/testing-library/jest-dom |
What jest-dom is
jest-dom provides 28+ custom Jest matchers targeting DOM state queries (attributes, classes, visibility, accessibility roles, form state). It integrates with Jest, Vitest, and Jest-compatible test runners, and works alongside @testing-library packages for query-based assertions.
Get the jest-dom source
Clone the repository and explore it locally.
git clone https://github.com/testing-library/jest-dom.gitcd jest-dom# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Import in a Jest setup file (setupFilesAfterEnv) to extend expect globally; use @testing-library/jest-dom/jest-globals if injectGlobals is false.
- Requires TypeScript setup: ensure setup file is .ts and included in tsconfig.json if using TypeScript for proper type definitions.
- Matchers inspect live DOM; use synchronously after queries resolve or after async/act() calls to avoid stale assertions.
- 142 open issues suggest active development; review issue backlog for known matcher limitations before relying on edge cases.
- Install eslint-plugin-jest-dom for lint rules that prevent incorrect matcher usage and improve test maintainability.
When to avoid it — and what to weigh
- Not using Jest or Jest-compatible runner — jest-dom requires Jest or Vitest. If you use Mocha, Jasmine, or other test frameworks without Jest compatibility, this library cannot be used.
- Server-side only testing — jest-dom targets DOM nodes; it has no value for backend unit tests or server-side rendering validation that doesn't require DOM inspection.
- E2E browser testing — jest-dom is for unit/integration tests in a Jest environment. For Cypress, Playwright, or Selenium E2E tests, use framework-native assertions instead.
- Vue 2 or non-standard DOM environments — jest-dom is optimized for React and standard DOM. Vue 2 or custom DOM libraries may have limited matcher relevance.
License & commercial use
MIT License (MIT) – permissive open-source license. Allows unrestricted use, modification, and distribution in commercial and private projects, provided the license header is included.
MIT is a permissive, well-established license suitable for commercial use. No licensing restrictions on bundling or distribution. Verify your own legal compliance for liability; jest-dom is provided as-is.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
jest-dom is a test utility library with no network I/O, data storage, or authentication. Security posture depends on Jest and the DOM environment. No known CVEs mentioned in provided data. Requires review of dependency chain for production-like test environments.
Alternatives to consider
Chai with chai-dom
Chai assertions library with DOM matchers; use if Mocha or non-Jest test runners are your standard, or for different assertion style.
Vitest native assertions
Vitest's built-in expect has some DOM-like assertions; lighter if you run Vitest and don't need the full jest-dom matcher set.
Testing Library queries only
Use @testing-library queries directly without jest-dom matchers; less readable but avoids a dependency if you prefer manual assertions.
Build on jest-dom with DEV.co software developers
Integrate jest-dom into your Jest test suite to write more readable, maintainable DOM assertions. Get started with a simple npm install and one import.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
jest-dom FAQ
Can I use jest-dom with Vitest?
Does jest-dom check aria-disabled?
What is the difference between toBeEmptyDOMElement and toBeEmpty?
Do I need eslint-plugin-jest-dom?
Software developers & web developers for hire
Need help beyond evaluating jest-dom? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source testing integrations — and maintain them long-term.
Adopt jest-dom for clearer DOM tests
Integrate jest-dom into your Jest test suite to write more readable, maintainable DOM assertions. Get started with a simple npm install and one import.