IntelliJ Ultimate 2018.3 stopped supporting running Javascript tests with old Jest version

已回答

We have some projects still not using Jest version 23 yet(on Jest 19), after upgrading to IntelliJ Ultimate 2018.3, those tests refused to be run in the IDE environment.

When using IntelliJ Ultimate 2018.3 to run a single Jest test file, it seems to be using Jest-CLI parameters:  `--runTestsByPath`

When running the tests from a package using Jest older than 23, the response is:

```
● Unrecognized CLI Parameters:

Following options were not recognized:
["reporters", "runTestsByPath"]

CLI Options Documentation:
http://facebook.github.io/jest/docs/cli.html


Process finished with exit code 1

```

In IntelliJ Ultimate 2018.2.7, it uses parameters --testResultsProcessor and --testPathPattern which runs fine.

 

0
Avatar
Permanently deleted user

I still see this error on 2018.3.4 Preview (Ultimate Edition).

Is there another workaround instead of waiting for the next IntelliJ update?

Thanks.

0

currently IDEA checks both jest and react-scripts versions trying to figure out the needded params. Seems it failes for your particular setup. Can you share a sample project that can be used to recreate the issue?

0
Avatar
Permanently deleted user

It might be that the jest-util npm package is not compatible with the latest IntelliJ version. Unfortunately my project is very large with many dependencies. I don't have an easy way to share a small sample without it breaking.

Here's the console error I'm seeing when debugging one Jest test (by clicking on green arrow next to line numbers in IntelliJ):

"C:\Program Files\nodejs\node.exe" --require "C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.3\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-stdin-fix.js" C:\Users\username\go\src\ssmc-onnode\UI\node_modules\jest-cli\bin\jest.js --colors --reporters "C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.3\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-reporter.js" --verbose "--testNamePattern=^ConfirmationDialog One level confirmation - check properties$" --runTestsByPath C:/Users/username/go/src/ssmc-onnode/UI/__tests__/framework/components/ConfirmationDialog-test.js
C:\Users\username\go\src\ssmc-onnode\UI\node_modules\jest-util\build\validateCLIOptions.js:62
throw createCLIValidationError(unrecognizedOptions, allowedOptions);
^

● Unrecognized CLI Parameter:

Unrecognized option "runTestsByPath".

CLI Options Documentation:
http://facebook.github.io/jest/docs/cli.html


Process finished with exit code 1

 

In an older version of IntelliJ (I don't remember the exact version), Jest debugging works fine and the console shows this command:

"<C:\Program Files\nodejs\node.exe>" --inspect-brk=52946 --require "<C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.2\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-stdin-fix.js>" E:\git\go\src\ssmc-onnode\UI\node_modules\jest-cli\bin\jest.js --runInBand --colors "--reporters=C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.2\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-reporter.js" --testPathPattern ^E:.git.go.src.ssmc-onnode.UI.__tests__.framework.components.ConfirmationDialog-test\.js$ --testNamePattern "^ConfirmationDialog One level confirmation - submit button click$"

NOTE: this command was executed from a different development environment; directory paths may be different.

Thanks.

0

as I wrote, the cli args  being used depend of the detected jest version. Looks as if it can be determined properly with your setup, thus the issue. We can hardly fix it unless we have a project that shows it up.

we don't need your proprietary code, it can be a single dummy test script. But the project setup should match yours, so that the problem can be replicated when using it

0
Avatar
Permanently deleted user

Running into the same problem on 2018.3.4. Our project setup is also pretty large too, so it would be difficult trying to isolate this into a test project. Did you guys find a solution?

0
Avatar
Permanently deleted user

Peter, due to time constraints, I downgraded to 2018.2.7 and haven't looked back. Good luck!

1
Avatar
Permanently deleted user

Noted. Thanks Eric!

0
Avatar
Permanently deleted user

Hi - I'm seeing this issue as well - my project is using react-app-rewired, and needs to run the jest bin bundled with that.  I'm specifying this in the run configuration's jest package: '.../node_modules/react-app-rewired'

Could Idea use the jest version pointed at by the run configuration to figure out the needed params, instead of just looking in the jest and react-scripts folders as mentioned by Elena above?

0

it requires providing special support for react-app-rewired; please feel free to file a feature request for it to youtrack, https://youtrack.jetbrains.com/issues/WEB

0
Avatar
Permanently deleted user

Hi Elena - this is a regression.  Running Jest tests using react-app-rewired works fine in Idea 2018.2.7.  I don't think I should have to file a feature request for a feature that used to work in a previous version.

0

It's not a regression - as Jest cli has changed in new versions, we now have to somehow check what version is being used. It was not the case in Idea 2018.2.7 that only supported old cli args and didn't care about Jest version

0
Avatar
Permanently deleted user

Of course it is a regression.  It's a feature that used to work in a previous version of your software and now no longer works in the new version, all other things being equal: https://en.wikipedia.org/wiki/Software_regression. 

Your Jest runtime configuration supports selecting a custom Jest runtime. Given that, working out which command line params should be provided to that runtime should come from that runtime, not elsewhere.  If that is not possible/easy, maybe another config item on the run configuration to disable the newer Jest command line params?

0
Avatar
Permanently deleted user

I can confirm that this is a regression, I'm having the same issue. I run Webstorm 2018.3.5. I tried Webstorm 2019.1 EAP, same issue, and rolled back to Webstorm 2018.2.7, which fixed the problem. 

0

What version of Jest can I downgrade to so IntelliJ works again? All I did was upgrade IntelliJ and now all my unit tests won't run.

0

You need upgrading Jest, not downgrading it

0
Avatar
Permanently deleted user

Seems to be fixed in webstorm EAP 2019.2

0
Avatar
Permanently deleted user

Still an issue for us on 2019.2

0
Avatar
Permanently deleted user

Found a workaround. For whatever reason, we only have this problem with jest 23. Manually configuring our run/debug config to use jest 20 fixed the problem for us, since it's not misinterpreting the jest version as needing the newer config format.

 

0

请先登录再写评论。