WebStorm chooses Jest over Karma for running individual tests

When I press the left-gutter buttons to run individual unit tests, WebStorm is always running them using Jest, even though I have the Karma plugin installed.  I am wanting to run them using Karma.  WebStorm should at least give me a choice between the two runners.

6 comments

What is your IDE version?

Please provide your package.json.

0

Thank you for responding.

The version is WebStorm 2018.1.5 Build #WS-181.5281.31, built on June 14, 2018.

package.json:

{
"name": "myproject",
"version": "0.0.0",
"license": "",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "node ./scripts/fetch-fragment-types & ng serve",
"test": "ng test",
"lint": "./node_modules/.bin/tslint --project \"./src/tsconfig.json\" \"./src/**/*.ts\"",
"e2e": "ng e2e",
"postinstall": "node postinstall.js"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{ts,tsx,scss}": [
"prettier --write",
"git add"
]
},
"private": true,
"dependencies": {
"@angular-redux/store": "6.5.7",
"@angular/animations": "4.4.7",
"@angular/cli": "1.4.3",
"@angular/common": "4.4.7",
"@angular/compiler": "4.4.7",
"@angular/compiler-cli": "4.4.7",
"@angular/core": "4.4.7",
"@angular/forms": "4.4.7",
"@angular/http": "4.4.7",
"@angular/platform-browser": "4.4.7",
"@angular/platform-browser-dynamic": "4.4.7",
"@angular/platform-server": "4.4.7",
"@angular/router": "4.4.7",
"@kbra/apollo-cache-redux": "0.1.0",
"@kbra/kbra-redux-utilities": "0.1.2",
"@ng-bootstrap/ng-bootstrap": "1.0.0-beta.1",
"@types/d3": "4.10.0",
"@types/gsap": "1.19.1",
"@types/lodash": "4.14.104",
"@types/redux-devtools-extension": "2.13.2",
"ajv": "5.2.2",
"angular2-notifications": "0.7.7",
"angular2-text-mask": "8.0.4",
"apollo-angular": "1.0.0",
"apollo-cache-inmemory": "1.1.0",
"apollo-client": "2.0.4",
"apollo-link": "1.2.1",
"apollo-link-batch-http": "1.1.1",
"apollo-link-http": "1.3.2",
"bootstrap": "4.0.0-alpha.6",
"classlist.js": "1.1.20150312",
"classnames": "2.2.5",
"core-js": "2.5.6",
"d3": "4.10.0",
"dom-helpers": "3.3.1",
"element-closest": "2.0.2",
"fixed-data-table-2": "^0.8.13",
"graphql": "0.11.7",
"graphql-tag": "1.3.2",
"gsap": "1.20.2",
"isomorphic-fetch": "2.2.1",
"jasmine-core": "2.7.0",
"jasmine-spec-reporter": "3.3.0",
"jquery": "3.2.1",
"karma": "1.7.0",
"karma-chrome-launcher": "2.2.0",
"libphonenumber-js": "1.2.12",
"lodash": "4.17.4",
"minimist": "1.2.0",
"moment": "2.18.1",
"ng2-img-cropper": "0.9.0",
"ngx-bootstrap": "2.0.2",
"ngx-infinite-scroll": "0.5.1",
"ngx-markdown": "^1.5.2",
"node-fetch": "1.7.3",
"node-sass": "4.7.2",
"objectFitPolyfill": "^2.1.1",
"popper.js": "1.11.1",
"protractor": "5.1.2",
"raven-js": "3.22.1",
"react": "16.4.0",
"react-d3-tree": "^1.10.6",
"react-dimensions": "^1.3.1",
"react-dom": "16.4.0",
"react-scripts-ts": "2.16.0",
"redux": "3.7.2",
"redux-observable": "0.17.0",
"replace-in-file": "3.4.0",
"rxjs": "5.5.10",
"topojson": "3.0.0",
"ts-helpers": "1.1.2",
"ts-node": "2.1.2",
"tslint": "5.9.1",
"tslint-angular": "1.1.1",
"typescript": "2.7.2",
"valid-data-url": "0.1.4",
"web-animations-js": "2.3.1",
"zone.js": "0.8.16"
},
"devDependencies": {
"@kbra/tslint-microsoft-contrib-release": "5.0.4",
"@types/jasmine": "2.5.43",
"@types/node": "6.0.85",
"@types/react": "16.3.14",
"@types/react-dom": "16.0.5",
"codelyzer": "4.2.1",
"husky": "^0.14.3",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "0.2.3",
"karma-jasmine": "1.1.0",
"karma-scss-preprocessor": "3.0.0",
"lint-staged": "^7.2.0"
}
}
0

Strange... The logic used for determining what test runner is available for a given test file is based on dependencies declarations in package.json nearest to the current file... But you don't have jest listed among dependencies... But you do have react-scripts-ts there - it can be the issue. Do you have any other package.json files in your project?

0

The only other package.json files are in the node_modules folder.   

It seems like, if I have karma listed in the package.json for my project, WebStorm should give me a Karma option when running individual tests, no matter what else I have in my project.  Wouldn't you agree?

0

I think that it would be better to let the user configure the default runner explicitly; please vote for https://youtrack.jetbrains.com/issue/WEB-28397

0

Please sign in to leave a comment.