vue.js - Jest 和 Vue 的覆盖率报告不起作用
问题描述
我正在使用 Jest 对我的 Vue 项目进行单元测试,我在控制台中获得了代码覆盖率,那里没有问题,但是 HTML 报告不起作用 -
包.json:
...
"unit": "jest --config test/unit/jest.conf.js --coverage",
...
jest.conf.js:
const path = require('path')
module.exports = {
verbose: true,
testURL: "http://localhost/",
rootDir: path.resolve(__dirname, '../../'),
moduleFileExtensions: [
'js',
'json',
'vue'
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
},
testPathIgnorePatterns: [
'<rootDir>/test/e2e'
],
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
setupFiles: ['<rootDir>/test/unit/setup'],
mapCoverage: true,
coverageDirectory: '<rootDir>/test/unit/coverage',
collectCoverageFrom: [
'src/**/*.{js,vue}',
'!src/main.js',
'!src/router/index.js',
'!src/plugins/vuetify.js',
'!**/node_modules/**'
]
}
这可能是什么原因?先感谢您。
解决方案
看起来您的覆盖率报告属性可能需要调整。您应该尝试包括html
在您的 中coverageReporters
,如下所示:
module.exports = {
...
coverageReporters: ['html']
...
}
推荐阅读
- java - 迭代 ImmutableMap.copyof() 时出现 ConcurrentModificationException
- angular - Azure 部署的 SPA 应用程序注册重定向 url 提供资源不可用
- git - 如何使用 git 我可以知道“刚刚发生推送”到主分支?
- python - Python MemoryError试图散列字符串
- c# - 在 Xamarin Android 上实现下载侦听器接口
- html - 图片与 GitHub Pages 上的文字不对齐
- discord.py - Discord.py 在不使用添加字段的情况下发送嵌入
- r - R中的累积和与多列的条件
- python - 从特定网站抓取已停止工作
- excel - 识别具有特定模式的字符串