我怎么知道我的测试覆盖了多少百分比?
How can I know what percentage is covered by my tests?
我想知道我的项目有多少被我的测试覆盖了,我目前正在尝试使用 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",
你的错误是
bash: jest: command not found
这意味着您的 project/installed 中没有添加笑话。安装它:npm install --save-dev jest
.
我想知道我的项目有多少被我的测试覆盖了,我目前正在尝试使用 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",
你的错误是
bash: jest: command not found
这意味着您的 project/installed 中没有添加笑话。安装它:npm install --save-dev jest
.