jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.84k stars 293 forks source link

Extension thinks I'm using old jest #121

Closed flaviut closed 6 years ago

flaviut commented 7 years ago

I get this message on vscode startup: "This extension relies on Jest 20+ features, it will continue to work, but some features may not work correctly."

But I am using jest 20, installed into my node_modules:

$ node_modules/.bin/jest -v
v20.0.4
yantakus commented 7 years ago

The same thing for me. Any ideas?

flaviut commented 7 years ago

Maybe a workaround would be to add jest@20.0.4 to your package file instead of just jest-cli.

I'm not getting the error anymore, but IDK what I did.

orta commented 7 years ago

That could be it, I don't use global commands like that - so it's likely that in all my projects there's a direct dependency on Jest's internals

hmontes commented 7 years ago

Same thing here. Create React App 1.0.7 with macOs

JasonSooter commented 7 years ago

I still received the error after adding jest@20.0.4 to my Create-React-App package.json.

I then updated react-scripts (used by CRA), restarted Code and the error was gone.

My guess is that my react-scripts package (version 0.9.4) used by CRA had a reference to Jest 19.

react-scripts package.json on May 15th

react-scripts package.json upgrade to Jest 20

Upgrading to react-scripts 1.0.10 which uses Jest 20.0.4 and it fixed the error for me.

Not sure if its a fix but it worked for me. Also, not even sure if @flaviut is even using CRA but maybe a package in the project is referencing an old version of Jest

gaearon commented 7 years ago

I still received the error after adding jest@20.0.4 to my Create-React-App package.json.

Note: this is entirely unsupported by Create React App. If you add jest to package.json in a Create React App project, we make no guarantees that tests will work in the future.

robertmain commented 6 years ago

I just saw this. Using vue webpack template

seanpoulter commented 6 years ago

What steps can we take to reproduce that problem @robertmain? The vuejs-templates/webpack repo is using Jest 21 so it might be worth looking into. If you run npm ls jest or yarn list jest in that directory, what version of Jest do you get?

robertmain commented 6 years ago
$ yarn list jest
yarn list v1.3.2
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ jest@21.2.1
Done in 1.38s.
$ npm run unit

> dashboard@1.0.0 unit C:\Users\robert\Code\Node\dashboard
> jest test/unit/specs --coverage

No tests found
In C:\Users\robert\Code\Node\dashboard
  28 files checked.
  testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 1 match
  testPathIgnorePatterns: \\node_modules\\ - 28 matches
Pattern: test/unit/specs - 0 matches
----------|----------|----------|----------|----------|----------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files |  Unknown |  Unknown |  Unknown |  Unknown |                |
----------|----------|----------|----------|----------|----------------|

You can find the repo here: http://glow.dev.maio.me/impulse/dashboard/tree/develop/

seanpoulter commented 6 years ago

Do you continue to see the warning about the old version of Jest @robertmain? I couldn't reproduce the issue with your repo and the latest version of the extension. I didn't not appear for me.

Also in your console output, no tests were found running npm run unit because that testPathPattern test/unit/specs doesn't work on Windows. Here's the relevant issue: facebook/jest#3793

robertmain commented 6 years ago

Do you continue to see the warning about the old version of Jest @robertmain? I couldn't reproduce the issue with your repo and the latest version of the extension. I didn't not appear for me.

I actually uninstalled the extension when it first started happening because I couldn't make it behave. I re-installed it when I saw your comment so I'd guess that fixed it :)

Also in your console output, no tests were found running npm run unit because that testPathPattern test/unit/specs doesn't work on Windows

Yeah, I've noticed that - I've taken to using npx jest --watch instead

TreTuna commented 6 years ago

@seanpoulter I'm running into this same issue right now starting a new project with "jest-cli" installed and not "jest". I noticed this originally while using React Boilerplate so that may be a good way for you to reproduce. All you have to do is follow their instructions to download, run the setup, open it in VSC and I'm getting the error. Once I add the normal Jest package the error goes away, but this is a bit counter-intuitive to have both jest-cli and jest packages.

seanpoulter commented 6 years ago

Oh? Thanks for following up @TreTuna. Any chance you've got some time to debug the extension on your machine? The error message is shown in this code method.

TreTuna commented 6 years ago

@seanpoulter Found where it was checking the path to Jest and added a line (and subsequent test) to check for jest-cli as well. Opened a PR for this. #243

seanpoulter commented 6 years ago

Thanks for figuring that out and contributing @TreTuna!