Vue 测试工具观察测试

2 javascript vue.js jestjs vue-cli vue-test-utils

我如何npm run test:unit在编写和保存测试时保持命令运行,我需要像npm run serve热重载这样的东西,我已经试过了,npm run test:unit --watch但它不起作用。

tmh*_*005 5

我建议注册一个新的命令脚本来观看测试以--watch直接使用以下选项vue-cli-service

package.json

{
  "scripts": {
     // ...
    "test:unit:watch": "vue-cli-service test:unit --watch",
  }
}
Run Code Online (Sandbox Code Playgroud)

然后你会运行:

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
Run Code Online (Sandbox Code Playgroud)