Lint-staged: dependency on `jest-validate` breaks tests in create-react-app

Created on 22 Mar 2018  路  12Comments  路  Source: okonet/lint-staged

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

? Needs Validation ? help wanted

Most helpful comment

This is a jest issue (https://github.com/facebook/jest/issues/5294), which has been fixed. CRA uses jest 20 though, which still has the bug (upgraded to 22 in the alpha).

All 12 comments

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

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.

This is a jest issue (https://github.com/facebook/jest/issues/5294), which has been fixed. CRA uses jest 20 though, which still has the bug (upgraded to 22 in the alpha).

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

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?

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.

@SimenB This is not https://github.com/facebook/jest/issues/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?

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

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

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

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

Thanks @gaearon for working on it!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OriginUnknown picture OriginUnknown  路  4Comments

acusti picture acusti  路  6Comments

okonet picture okonet  路  5Comments

okcoker picture okcoker  路  4Comments

yoannmoinet picture yoannmoinet  路  8Comments