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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: environment.dispose is not a function #5401

Closed
ShMcK opened this issue Jan 26, 2018 · 16 comments
Closed

TypeError: environment.dispose is not a function #5401

ShMcK opened this issue Jan 26, 2018 · 16 comments

Comments

@ShMcK
Copy link

ShMcK commented Jan 26, 2018

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"

@ShMcK
Copy link
Author

ShMcK commented Jan 26, 2018

Fix: installed jest globally rather than running from local npm script.

@ShMcK ShMcK closed this as completed Jan 26, 2018
@spudly
Copy link

spudly commented Jan 29, 2018

Just ran into the same issue. Upgraded jest and the error went away.

@etcetera8
Copy link

npm install jest-cli fixed this one for me

@SimenB
Copy link
Member

SimenB commented Feb 10, 2018

Should be fixed in newer versions of jest (22.2.0+). See #5294, #5304 and #5353

@wilhelmklopp
Copy link

wilhelmklopp commented Feb 12, 2018

Updating Jest didn't fix this for me.

npm install jest-cli fixed this one for me

But this did 🙌

@AndreiCalazans
Copy link

I also had to uninstall jest first,
npm uninstall jest
then do
npm install jest-cli

I'm using create-react-app.

@matej-prokop
Copy link

If you are using create-react-app then TypeError: environment.dispose is not a function is very probably caused by clash of jest-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. (lint-staged/lint-staged#414)

@jonathan-stone
Copy link
Contributor

I got this using create-react-app after installing jest-enzyme.
Fixed by updating jest with yarn upgrade jest.

@gaearon
Copy link
Contributor

gaearon commented Apr 3, 2018

It is not supported to "upgrade Jest" inside a CRA-managed project. If you have both react-scripts and jest in your package.json things will go badly wrong in the future.

@gaearon
Copy link
Contributor

gaearon commented Apr 3, 2018

I filed a new issue for this problem. I think it's a Jest bug (that hasn't been fixed yet). #5913

@gaearon
Copy link
Contributor

gaearon commented Apr 3, 2018

@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!

@gaearon
Copy link
Contributor

gaearon commented Apr 3, 2018

I published [email protected] which should fix environment.dispose is not a function for CRA users.

https://github.com/facebook/create-react-app/releases/tag/v1.1.3

@harunurhan
Copy link

harunurhan commented Apr 24, 2018

I have the same problem, because I run ui tests with different config (puppeteer) and running them as a different package.json script directly via jest .... It works if I yarn add --dev jest-cli but this breaks react-scripts test which I use to run unit tests etc.

@arminyahya
Copy link

I fixed this problem by updating jest.

@yinshangwei
Copy link

I also had to uninstall jest first,
npm uninstall jest
then do
npm install jest-cli

I'm using create-react-app.

Ya, this works for me.

@github-actions
Copy link

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 May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests