Vue Cli unit test with jest how to run single test
If you want to execute only single file then simply do:
npm run test:unit -t counter
OR
npm run test:unit counter
Whereas counter.spec.js is the my test file.
The Vue CLI service respects Jest's CLI options, so you can append them to commands in package.json
, e.g
{
...
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:only": "vue-cli-service test:unit --testPathPattern=user.store",
},
"dependencies": {
testPathPattern
takes a regex which applies to the spec file names, so in my tests if I specify the pattern
--testPathPattern=user.store
I run a single spec file, but if I specify
--testPathPattern=store
I run multiple matching spec files with store
in the name.
Here is the Jest docs ref