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?


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'

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?


I created  a minimal angular 7 project with karma removed and jest added here:

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



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


There seems to be a fix in the angular-builders package soon, but the maintainer suggests a fix for intellij as well:


This issue exists in 2019.1.2. I upgraded from 2018.2.3 yesterday and can no longer run inline jest tests through the IDE anymore. The configurations between the 2 versions are identical (I didn't change anything from the defaults) and the difference in the running of the tests is very small, but causes the tests not to run.

When running in 2018.2.3 it runs:

/Users/adam/.nvm/versions/node/v10.10.0/bin/node --require /Applications/PhpStorm.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-stdin-fix.js /Users/adam/src/projects/phoenix/node_modules/jest-cli/bin/jest.js --config jest.config.json --colors --testResultsProcessor /Applications/PhpStorm.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-test-results-processor.js --testPathPattern ^/Users/adam/src/projects/phoenix/app/modules/custom/amaysim_energy_product_comparison/js/__test__/DataLayerPush\.test\.js$ "--testNamePattern=^data layer push help button click$"

And 2019.1.2:

/Users/adam/.nvm/versions/node/v10.10.0/bin/node --require "/Users/adam/Library/Application Support/JetBrains/Toolbox/apps/PhpStorm/ch-0/191.7141.52/PhpStorm.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-stdin-fix.js" /Users/adam/src/projects/phoenix/node_modules/jest-cli/bin/jest.js --config jest.config.json --colors --reporters "/Users/adam/Library/Application Support/JetBrains/Toolbox/apps/PhpStorm/ch-0/191.7141.52/PhpStorm.app/Contents/plugins/JavaScriptLanguage/helpers/jest-intellij/lib/jest-intellij-reporter.js" --verbose "--testNamePattern=^data layer push help button click$" --runTestsByPath /Users/adam/src/projects/phoenix/app/modules/custom/amaysim_energy_product_comparison/js/__test__/DataLayerPush.test.js

Throwing an error:
Unrecognized options: reporters, runTestsByPath



I get this result in the latest version, too. I can run tests globally on the project, but I get an error if I try to run an individual test.


what is your Jest version? Is it listed in your package.json?

"jest-cli": "20.x",
"jest-dom": "^1.11.0",

Please sign in to leave a comment.