canirequire

canirequireDual (CommonJS + ESM) › @testing-library/jest-dom

Is @testing-library/jest-dom ESM-only? Can you require() it?

Custom jest matchers to test the state of the DOM

Last verified Sep 9, 2026 against @testing-library/jest-dom@7.0.1. JSON

Dual (CommonJS + ESM) Dual package — both require() and import work

@testing-library/jest-dom publishes both a CommonJS entry and a native ESM entry (ESM added in 6.1.0). require("@testing-library/jest-dom") and import "@testing-library/jest-dom" both work on every supported Node.js version and in Bun.

Latest
7.0.1 (Aug 9, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
7.0.1
Native ESM since
6.1.0
TypeScript types
Bundled
Node engines
>=22
Weekly downloads
56.0M
License
MIT

Does @testing-library/jest-dom@7.0.1 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("@testing-library/jest-dom") from a CommonJS file and import "@testing-library/jest-dom" from an ES module.

Runtimerequire("@testing-library/jest-dom")import "@testing-library/jest-dom"
Node.js 18✗ failsReferenceError✗ failsReferenceError
Node.js 20✗ failsReferenceError✗ failsReferenceError
Node.js 22✗ failsReferenceError✗ failsReferenceError
Node.js 24✗ failsReferenceError✗ failsReferenceError
Node.js 26✗ failsReferenceError✗ failsReferenceError
Bun 1.4✗ failsReferenceError✗ failsReferenceError

A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.

How to import @testing-library/jest-dom

ES modules (import)

import jestDom from "@testing-library/jest-dom";

CommonJS (require)

const jestDom = require("@testing-library/jest-dom");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (84 versions; the newest 60 shown).

VersionsFormatFirst published
6.1.0 – 7.0.1Dual (CommonJS + ESM)Aug 23, 2023
5.10.0 – 6.0.1CommonJSJun 11, 2020

Frequently asked

Is @testing-library/jest-dom ESM-only?

@testing-library/jest-dom@7.0.1 ships CommonJS and ESM builds. @testing-library/jest-dom publishes both a CommonJS entry and a native ESM entry (ESM added in 6.1.0). require("@testing-library/jest-dom") and import "@testing-library/jest-dom" both work on every supported Node.js version and in Bun.

Can I require @testing-library/jest-dom?

Yes. @testing-library/jest-dom ships a CommonJS entry, so require("@testing-library/jest-dom") works on every Node.js version, alongside the native ESM entry for import.

Does @testing-library/jest-dom work in Bun?

Importing @testing-library/jest-dom failed in Bun 1.4 on Sep 9, 2026: ReferenceError: expect is not defined

Does @testing-library/jest-dom ship TypeScript types?

Yes. @testing-library/jest-dom bundles its own type declarations; no @types package is needed.

Links

Other dual (commonjs + esm) packages

Similar popularity