Running .spec.js Tests defaults to Jest
I'm using tape for my node.js unit and integration tests and name the test files according to the "module.spec.js" scheme. Prior to 2018.3 I was able to right-click the test file and execute it as a node.js script, which is the intended usecase for tape tests. Since 2018.3 running .spec.js files via right click->run defaults to "Jest" which I do not use and also doesn't work with tape files (" ERROR command "test:unit" does not exist"). I didn't find a setting in PHPStorm where I can disable this behavior. Also as far as I know, the .spec.js naming scheme is not exclusive for Jest tests, so this makes me really wonder about this decision.
请先登录再写评论。
The logic used for determining what test runner is available for a given test file is based on dependencies declarations in
package.jsonnearest to current file. Do you have '@vue/cli-service'or'jest'listed as a dependency/dev dependency in yourpackage.json?I'm running a vue-cli3 project and thus have declared the `@vue/cli-service` dependency in package.json. After a quick search in the vue-cli3 docs I found only one reference to Jest which states it's required to install another extension plugin to run Jest tests with vue-cli. With this in mind, I would propose not to use `@vue/cli-service` in package.json to determine Jest as the type of test runner for a project.
It has been done at users' requests, see https://youtrack.jetbrains.com/issue/WEB-34734... Jest is actually a standard choice for unit testing when creating a project with vue-cli 3:
We have a feature request for a possibility to choose the test runner explicitly, https://youtrack.jetbrains.com/issue/WEB-28397. Please follow it for updates