Skip to content
Latchkey

Jest "Test environment jest-environment-jsdom cannot be found"

Since Jest 28 the jsdom environment is no longer bundled. If your config asks for testEnvironment: "jsdom" but jest-environment-jsdom is not installed, Jest cannot find it and aborts.

What this error means

After bumping Jest to 28 or newer, the run fails immediately with "Test environment jest-environment-jsdom cannot be found." It started failing on a version upgrade, not a code change.

Jest output
Error: Test environment jest-environment-jsdom cannot be found. Make
sure the testEnvironment configuration option points to an existing
node module.

As of Jest 28 "jest-environment-jsdom" is no longer shipped by default.

Common causes

jsdom unbundled since Jest 28

Jest 28 removed the jsdom environment from the core package to shrink installs. Projects that rely on jsdom must now add jest-environment-jsdom explicitly.

Version mismatch between jest and the environment

A jest-environment-jsdom pinned to a different major than jest may not be resolvable, producing the same "cannot be found" error.

How to fix it

Install the jsdom environment package

Add it as a dev dependency at the same major version as Jest.

Terminal
npm install -D jest-environment-jsdom
# match the jest major version
npm install -D jest-environment-jsdom@29

Point testEnvironment at the package

jest.config.js
// jest.config.js
module.exports = { testEnvironment: 'jsdom' };
// equivalently: testEnvironment: 'jest-environment-jsdom'

How to prevent it

  • Add jest-environment-jsdom to devDependencies for DOM suites.
  • Keep the environment package’s major version aligned with Jest.
  • Read Jest upgrade notes before bumping major versions in CI.

Frequently asked questions

What causes ""jest-environment-jsdom cannot be found""?
Jest 28 removed the jsdom environment from the core package to shrink installs. Projects that rely on jsdom must now add jest-environment-jsdom explicitly.
How do I fix "jest-environment-jsdom cannot be found"?
Add it as a dev dependency at the same major version as Jest.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card