-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: environment.teardown is not a function at node_modules/jest-runner/build/run_test.js #6393
Comments
I'm also experiencing the same issue. |
I managed to make it work after deleting package-lock.json, yarn.lock, node_modules, removing jest from the dependencies in package.json, then doing npm install and yarn install! |
If you use CRA, you shouldn't install Jest yourself - it comes with CRA out of the box 🙂 See e.g. #5119 (comment) |
Same issue with clean CRA. FAIL src/App.test.js
Ran npx envinfo --preset jest |
Before I could run the tests though the script was complaining that it was missing the jest-cli. I installed that, then got this error. |
For me a workaround was removing the config option |
Again, don't install Jest if you use CRA |
Was able to fix using @FaabLondon's suggestion above. |
Same issue for me with or without standalone Jest. I tried @FaabLondon 's suggestion but no luck. The issue tends to happen after installing a new package. System: |
@louishoang I have a few questions in order to gauge your development environment and when the issue is occurring on your machine.
|
@iostate , please have a look at this gist
|
Before installing jest and jest-cli and I had exact the same error as @louishoang. Now I'm having the "TypeError: environment.teardown is not a function" issue. I'm running OSX 10.12.6 |
Same issue from AppCenter:
|
Worked when I used the same jest version as the react scripts jest version. Which in my case is |
@revanthCopart Did you have to install jest-cli? And if you do, what is the version that works for you? |
@louishoang I had to install |
Thanks, @revanthCopart! I managed to get back on track by doing the following steps:
|
I had to also install Error Stack
Environment
EDIT: Solved Do not simply run |
I am using jest version 21.2.1. |
|
Followed these instructions: jestjs/jest#6393 (comment)
Just FYI. In my TS project that doesn't use CRA I was getting
The solution was to align
The higher version of |
@pwlmaciejewski thank you for that. I was encountering this using an ejected CRA (without typescript) where I had When I aligned my versions of |
I followed these steps
|
Following the above steps but using version
|
@tratnayake your solutions works like a charm. |
@tratnayake, good job! |
@citius, good job! I followed your instructions and deleted jest-cli. Tests are working now. |
I followed these steps Delete node modules folder |
Same with me delete and reload the node Modules and it's working. |
I fixed this by removing |
had the same issue @FaabLondon's solution above helped me fix it. |
I installed some jest packages, and like everyone said, it kept throwing the same error, UNTIL I deleted |
I'm having this problem currently because I am attempting to use the inlineSnapshots feature which is not available in the version installed via CRA. I've submitted a feature request to CRA to upgrade but in the interim, is there any workaround to allow use of inlineSnapshots in a CRA project? |
eject or react-app-rewired |
@tratnayake Thanks mate! |
This problem is coming up again. I removed yarn.lock, package-lock.json and node_modules |
Was able to fix using @FaabLondon's suggestion above. |
We're not supposed to install it explicity <sigh>. Installing it is not a fix for the "environment.teardown is not a function" error. This is: jestjs/jest#6393 (comment)
In my case there was one of my dependencies that depended on an old jest version that caused it. After doing a grep -A3 _requiredBy node_modules/jest-environment-jsdom/package.json I found out which package was the cause of it ( which included jest as dependency instead of devDependency ). Moving jest to devDeps on that package fixed the issue. |
I deleted the "jest-cli" dependency and run "yarn install". Now it works! |
Got this error when I ran `npm test`: > TypeError: environment.teardown is not a function Followed this advice: jestjs/jest#6393 (comment)
|
hi i remove node-modules and yarn and package-lock.json && then install yarn first then yarn add [email protected] and in the end npm install and it works for me . |
Hi, i fixed my issue with the following steps:
|
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. |
🐛 Bug Report
Hello, I have used create React app and can't make the tests work.
Initially, I got an error message with jest and jest-cli so installed jest with npm install --save-dev jest and then jest-cli with npm install jest-cli.
However, I still get the following message:
Test suite failed to run
TypeError: environment.teardown is not a function
at node_modules/jest-runner/build/run_test.js
Run
npx envinfo --preset jest
Paste the results here:
System:
OS: macOS High Sierra 10.13.2
CPU: x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
Binaries:
Node: 9.4.0 - ~/.nvm/versions/node/v9.4.0/bin/node
Yarn: 1.6.0 - /usr/local/bin/yarn
npm: 6.1.0 - ~/.nvm/versions/node/v9.4.0/bin/npm
npmPackages:
jest: ^23.1.0 => 23.1.0
The text was updated successfully, but these errors were encountered: