Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have to specified testEnvironment in jest.config.js file in v27.0.3? #11494

Closed
LiJiahaoCoder opened this issue May 31, 2021 · 3 comments
Closed

Comments

@LiJiahaoCoder
Copy link

馃悰 Bug Report

Default test environment in jest is jsdom. But all my test cases crashed after I upgraded my jest to 27.0.3.

But when I specified testEnvironment: 'jsdom' in jest.config.js, it works!

To Reproduce

Steps to reproduce the behavior:

  1. Upgrade jest to 27.0.3;
  2. Run jest command in React project;

Expected behavior

Expect that all test cases passed, but it crashed and logged the message as follows:

The error below may be caused by using the wrong test environment,see https://jestjs.io/docs/configuration#testenvironment-string.

    Consider using the "jsdom" test environment.

Link to repl or repo (highly encouraged)

webpack-react-template

envinfo

jest: 27.0.3
node: 14.16.1
react: ^17.0.2
OS: MacOS Big Sur 11.2.1

Maybe it was cause by this: https://github.com/facebook/jest/pull/11482/files#diff-9dbb1da56fa2045712eef8db063b52b3555a799b93e858b7449b5561bef52d9fR613

@LiJiahaoCoder LiJiahaoCoder changed the title Have to specified testEnvironment in jest.config.js file in v27.0.3? Have to specified testEnvironment in jest.config.js file in v27.0.3? May 31, 2021
@ahnpnl
Copy link
Contributor

ahnpnl commented May 31, 2021

Jest 27 default testEnvironment is node. If you need to use jsdom, you need to specify it yourself.

@SimenB
Copy link
Member

SimenB commented May 31, 2021

Default changed in v27 to node, as pointed out in the changelog and blog post

@SimenB SimenB closed this as completed May 31, 2021
@github-actions
Copy link

github-actions bot commented Jul 1, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants