【发布时间】:2022-02-08 00:39:57
【问题描述】:
我想知道我的测试涵盖了我的项目的多少,我目前正在尝试使用 jest 来做到这一点。
这是我的jest.config.js:
module.exports = {
verbose: true,
preset: '@vue/cli-plugin-unit-jest',
transform: {
'^.+\\.vue$': 'vue-jest',
},
jest: {
coverageThreshold: {
global: {
branches: 50,
functions: 50,
lines: 50,
statements: 50,
},
'./src/components/': {
branches: 40,
statements: 40,
},
'./src/reducers/**/*.js': {
statements: 90,
},
'./src/api/very-important-module.js': {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
},
}
但是当我尝试运行命令jest --coverage --coverageReporters="json-summary"
我收到错误:bash: jest: command not found
如何解决此错误?
我的 devDependecies 是:
"eslint-plugin-vue": "^7.0.0",
"jest": "^27.5.0",
"jest-cli": "^27.5.0",
【问题讨论】:
-
如果您看到
jest command not found,这仅表示您尚未将jest添加到您的项目中。运行yarn install jest -D。或npm i jest -D。添加后,您将在控制台中看到覆盖范围(或保存到文件中,具体取决于您运行的命令)。
标签: javascript vue.js jestjs