【发布时间】:2018-06-02 06:43:17
【问题描述】:
我正在尝试获取我的 node.js 项目的代码覆盖率。为此,我正在使用摩卡咖啡和伊斯坦布尔。但我得到0通过 伊斯坦布尔:没有收集到覆盖信息,不写覆盖信息就退出 Mocha 和 istanbul 安装在本地。 package.json 中的脚本看起来像
"scripts": {
"test": "node_modules/.bin/mocha",
"test:coverage": "./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha"
}
文件夹结构如下 - - -项目 ----node_modules - -测试 - 单元 -01test1.tes.js -02test2.test.js
我的 .istanbul.yml 文件
verbose: false
instrumentation:
root: ./node_modules/.bin/istanbul
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
reporting:
print: summary
reports:
- lcov
dir: ./coverage
watermarks:
statements: [50, 80]
lines: [50, 80]
functions: [50, 80]
branches: [50, 80]
hooks:
hook-run-in-context: false
post-require-hook: null
我正在跑步
npm 运行测试:覆盖率
在终端(mac OSX)中。我对此相当陌生,因此非常欢迎任何输入。请帮帮我,我已经花了一整天的时间。
【问题讨论】:
标签: node.js mocha.js istanbul jscoverage