question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jest v28 environment error

See original GitHub issue

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:

  • Platform: win32
  • Arch: x64
  • Version: Windows 7 Ultimate Service Pack 1

Binaries:

  • Node: 12.22.1
  • npm: N/A
  • Yarn: N/A
  • pnpm: N/A

Relevant packages:

  • next: 12.1.7-canary.4
  • react: 17.0.2
  • react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

With jest of version 28+ npm run test ends in this error:

● Validation Error:

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

  Configuration Documentation:
  https://jestjs.io/docs/configuration


As of Jest 28 "jest-environment-jsdom" is no longer shipped by default, make sure to install it separately.

I’ve looked at the jest-environment-jsdom page and have some reservations about installing packages without a readme. So I thought jsdom would suffice, but it’s doesn’t and crashes with the same error.

Expected Behavior

Not crashing on test start.

To Reproduce

git clone https://github.com/GabenGar/repros.git repros
cd repros/nextjs/jest-env-error
npm install
npm run test

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
balazsorban44commented, May 12, 2022

The docs should already be updated in https://github.com/vercel/next.js/pull/36632, but it won’t show up on the documentation page before our next stable release.

I’ll make sure to update our with-jest example to use Jest 28 as well.

0reactions
github-actions[bot]commented, Jun 12, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

From v27 to v28 - Jest
Upgrading Jest from v27 to v28? This guide aims to help refactoring your configuration and tests.
Read more >
[Bug]: regression in v28 · Issue #12759 · facebook/jest - GitHub
I've fully removed both node_modules and package-lock.json file without results. Environment. System: OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 ( ...
Read more >
Error Test environment jest-environment-jsdom cannot be ...
I'm receiving an error: Error: Test environment jest-environment-jsdom cannot be found. Make sure the testEnvironment configuration option ...
Read more >
babel-jest - Awesome JS
[docs] Update link to Jest 28 upgrade guide in error message (#13483) ... [jest-environment-node] make globalThis.performance writable for Node 19 and fake ...
Read more >
jest - npm
Delightful JavaScript Testing.. Latest version: 29.3.1, last published: 2 months ago. Start using jest in your project by running `npm i ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found