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

dependency on jest-validate breaks tests in create-react-app #414

Closed
matej-prokop opened this issue Mar 22, 2018 · 12 comments
Closed

dependency on jest-validate breaks tests in create-react-app #414

matej-prokop opened this issue Mar 22, 2018 · 12 comments

Comments

@matej-prokop
Copy link

matej-prokop commented Mar 22, 2018

If you are using create-react-app and upgrade to link-staged 7.0.0 all your test starts to fail because of TypeError: environment.dispose is not a function

Reason is that lint-staged 7.0.0 started to depend on jest-validate which depends on jest-environment-node and there is clash between different versions of jest-environment-node from CRA and list-staged.

npm ls jest-environment-node

image

@okonet
Copy link
Collaborator

okonet commented Mar 22, 2018

I'm not sure what we should do about it. Probably it's better to report at CRA?

@matej-prokop
Copy link
Author

matej-prokop commented Mar 22, 2018

I enjoy using lint-stage so I felt that it is important to inform you that CRA projects are currently forced to stick with lint-staged version 6.x.x.

This sounds more like Jest issue than CRA stuff. Anyway, I understand your point.

@SimenB
Copy link
Contributor

SimenB commented Mar 25, 2018

This is a jest issue (jestjs/jest#5294), which has been fixed. CRA uses jest 20 though, which still has the bug (upgraded to 22 in the alpha).

@sudo-suhas
Copy link
Collaborator

Shall we close this issue? Do not see any action item for lint-staged.

@gaearon
Copy link

gaearon commented Apr 3, 2018

I created a new CRA project and ran yarn add lint-staged. I don't see this issue when running yarn test.
What's the full reproducing case?

@stevensacks
Copy link

It doesn't happen to me if I npm install lint-staged into an existing project, either. But if I delete package-lock.json and node_modules and then run npm install with lint-staged 7.x in my package.json, that's when it breaks.

@gaearon
Copy link

gaearon commented Apr 3, 2018

@SimenB This is not jestjs/jest#5294 although it looks similar.

The problem here is because jest-environment-* was also being resolved from the root directory instead of from jest's module directory. I'm not sure if this problem still exists, can you check that please?

@gaearon
Copy link

gaearon commented Apr 3, 2018

This code seems to still exist in Jest master so a similar problem could manifest itself in the future.

@gaearon
Copy link

gaearon commented Apr 3, 2018

I filed jestjs/jest#5913.

@gaearon
Copy link

gaearon commented Apr 3, 2018

I published react-scripts@1.1.3 which should fix environment.dispose is not a function for you.

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

@matej-prokop
Copy link
Author

@gaearon Thank you for jumping on this. It is great to have a new version of CRA mitigating this issue. 👍

Now, it is definitely time to close this issue.

@okonet
Copy link
Collaborator

okonet commented Apr 3, 2018

Thanks @gaearon for working on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants