【发布时间】:2016-07-08 10:54:11
【问题描述】:
我正在阅读关于 karma 和 istanbul 的文档以设置代码覆盖率。我不确定我错过了什么。我包括了我用来解决此步骤的所有内容,因此如果冗长,我深表歉意。
我尝试在我的 npm 包中运行启动脚本,但收到错误消息
Error: Cannot find module 'c:\HA\VSTS\Applications\HA.Web.Main\spec\support\jasmine.json'
-https://karma-runner.github.io/0.8/config/coverage.html
-https://www.npmjs.com/package/istanbul#getting-started
这似乎应该是一个相当简单的过程。
在我的 karma.conf 文件中,我有 karma-coverage
plugins: {
karma-coverage
]
我设置了一个报道对象
coverageReporter: {
// disable code compaction when using instrumenter * do not want ot minify output
instrumenterOptions: {
istanbul: { noCompact: true }
},
type: 'html',
dir: 'coverage/'
},
在预处理器中,我列出了我想要覆盖的文件
preprocessor: [
"../Scripts/src/modules/**/*.js": ['coverage']
]
文档记录了 windows 上的茉莉花,并确定了脚本对象需要使用跨平台。
"scripts": {
"test": "istanbul cover node_modules/jasmine/bin/jasmine.js"
},
我的节点模块中有茉莉花,所以这应该不是问题。
我跑去进一步确定可能是什么问题。
istanbul help config
但老实说,我现在不知道在这些对象中寻找什么
verbose: false
instrumentation:
root: .
extensions:
- .js
default-excludes: true
excludes: []
embed-source: false
variable: __coverage__
compact: true
preserve-comments: false
complete-copy: false
save-baseline: false
baseline-file: ./coverage/coverage-baseline.json
include-all-sources: false
include-pid: false
es-modules: false
reporting:
print: summary
reports:
- lcov
dir: ./coverage
watermarks:
statements: [50, 80]
lines: [50, 80]
functions: [50, 80]
branches: [50, 80]
report-config:
clover: {file: clover.xml}
cobertura: {file: cobertura-coverage.xml}
json: {file: coverage-final.json}
json-summary: {file: coverage-summary.json}
lcovonly: {file: lcov.info}
teamcity: {file: null, blockName: Code Coverage Summary}
text: {file: null, maxCols: 0}
text-lcov: {file: lcov.info}
text-summary: {file: null}
hooks:
hook-run-in-context: false
post-require-hook: null
handle-sigint: false
check:
global:
statements: 0
lines: 0
branches: 0
functions: 0
excludes: []
each:
statements: 0
lines: 0
branches: 0
functions: 0
excludes: []
【问题讨论】:
-
从命令行运行 istanbul 时出现同样的错误:
node_modules/istanbul/lib/cli.js cover node_modules/jasmine/bin/jasmine.js
标签: unit-testing karma-runner istanbul