2018.3 Seems to Break Jest Running

I've been using Jest for some time now without a problem, and recently I upgraded to 2018.3 and experienced a number of problems.

 

It looks like by default, WebStorm wants to run ng test now for all tests; it used to simply run the jest command, but this changed in my Run Configuration, causing my tests not to work. This wasn't too hard to fix, I just went to my Run Configuration and changed the Jest Package back to jest

The problem is when I try to run individual tests; it tries to run ng test. Now, I managed to change the angular.json to the Jest test runner so that indeed, ng test runs Jest and not Karma... but WebStorm passes along arguments to ng test that the jest cli doesn't understand, and I get this:

 

"C:\Program Files\nodejs\node.exe" --require "C:\Program Files\JetBrains\WebStorm 2018.2.6\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-stdin-fix.js" D:\rhythm\console\node_modules\@angular\cli\bin\ng test --colors --reporters "C:\Program Files\JetBrains\WebStorm 2018.2.6\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-reporter.js" --verbose "--testNamePattern=^ManageCustomFieldsComponent " --testPathPattern=^D:.rhythm.console.src.app.platform.shared-pages.customFields.manage-custom-fields.manage-custom-fields\.component\.spec\.ts$
Unknown option: '--reporters'
Unknown option: 'C:\Program Files\JetBrains\WebStorm 2018.2.6\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-reporter.js'
Unknown option: '--testPathPattern'

Process finished with exit code 1

 

Can you help?

8 comments

We have the same problem within our projects. This is the test part of our angular.json file:

"test": {
"builder": "@angular-builders/jest:run",
"options": {
"setupTestFrameworkScriptFile": "./setupJest.ts",
"detectOpenHandles": true,
"coverage": true
}
},


This is the run configuration for jest tests:

 

If we now want to run a single test by clicking on the run icon next to the spec, we get same errors Andrew described above:

Unknown option: '--reporters'
Unknown option: '/Applications/IntelliJ IDEA.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-reporter.js'
Unknown option: '--testPathPattern'
0

Created run configuration looks OK, and specified options are valid Jest cli args (https://jestjs.io/docs/en/cli.html).

Please can you share a sample project that can be used to recreate the issue?

0

I created  a minimal angular 7 project with karma removed and jest added here:
https://github.com/sroettering/jest-sample

This is the default angular app that is automatically generated. Starting any test from app.component.spec.ts results in the described errors.

0

Thanks!

seems to be the issue with cli. You will see similar errors when running ng test in terminal, like:

ng test --colors "--testNamePattern=^AppComponent " --testPathPattern=^C:.downloads.jest-sample.src.app.app\.component\.spec\.ts$

Unknown option: '--testPathPattern'

But, according to https://github.com/meltedspark/angular-builders/tree/master/packages/jest#builder-options, [jest-cli-option](any option from Jest CLI options) can be provided directly to ng test command.

And this used to work with earlier CLI versions...

0

There seems to be a fix in the angular-builders package soon, but the maintainer suggests a fix for intellij as well:
https://github.com/meltedspark/angular-builders/issues/150#issuecomment-454967702

0

Please sign in to leave a comment.