jest: TypeError: environment.dispose is not a function
What is the current behavior?
All tests files fail with the following error:
TypeError: environment.dispose is not a function
at Promise.resolve.then (../../../../../usr/local/lib/node_modules/jest/node_modules/jest-runner/build/run_test.js:116:17)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Tests were running yesterday.
Removing node_modules & reinstalling produced no difference.
Dependencies: “jest”: “^22.1.4”,
with presets: “jest-expo”: “^25.0.0”
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 16 (6 by maintainers)
npm install jest-cli
fixed this one for meI also had to uninstall jest first,
npm uninstall jest
then donpm install jest-cli
I’m using create-react-app.
@AndreiCalazans @jonathan-stone
Please, could you report such issues to CRA in the future? We had no idea people were doing workarounds like installing Jest into a CRA project (which is entirely unsupported and will break your projects later). If something doesn’t work in CRA out of the box, it’s CRA’s fault, and we want to be aware of it so we can fix it for our users. Thanks!
If you are using create-react-app then
TypeError: environment.dispose is not a function
is very probably caused by clash ofjest-environment-node
versions. Try to run:npm ls jest-environment-node
to see which of your dependencies is causing it.
In my case it was caused by upgrade of lint-staged to v 7.0.0. (https://github.com/okonet/lint-staged/issues/414)
I published
react-scripts@1.1.3
which should fixenvironment.dispose is not a function
for CRA users.https://github.com/facebook/create-react-app/releases/tag/v1.1.3
Updating Jest didn’t fix this for me.
But this did 🙌
Just ran into the same issue. Upgraded jest and the error went away.