How can I keep the npm run test:unit command running when I'm writing and saving my tests, I need something like npm run serve with hot reload, I've tried npm run test:unit --watch but it doesn't work.
How can I keep the npm run test:unit command running when I'm writing and saving my tests, I need something like npm run serve with hot reload, I've tried npm run test:unit --watch but it doesn't work.
I suggest to register a new command script for watching tests to use --watch option directly of vue-cli-service:
package.json
{
"scripts": {
// ...
"test:unit:watch": "vue-cli-service test:unit --watch",
}
}
Then you would run:
npm run test:unit:watch // or yarn test:unit:watch
// You can even run for specific test as well
npm run test:unit:watch -- yourTest.spec.ts
The npm docs state:
As of
npm@2.0.0, you can use custom arguments when executing scripts. The special option--is used bygetoptto delimit the end of the options.npmwill pass all the arguments after the--directly to your script:npm run test -- --grep="pattern"
So use this on the command line:
npm run test:unit -- --watch
Alternatively, you could use yarn, which doesn't require the run command or the separating --:
yarn test:unit --watch