【发布时间】:2014-08-19 21:31:59
【问题描述】:
我正在尝试使用 GruntJS 的 grunt-mocha-test 插件设置代码覆盖率。我关注了this guide,在“生成覆盖”部分下。
但是,运行 grunt 会生成一个 coverage.html 报告,该报告仅涵盖已运行的测试文件……而不是我的其他代码。
所以:
- 有人知道问题出在哪里吗?理想情况下,我不想使用另一个 grunt 插件。
- 如何过滤我的所有
/test/**文件以使其不包含在覆盖率报告中?
我的普通 mocha 测试通过 grunt 运行良好,只是覆盖率报告是问题。
BlanketJS 的文档在这里并没有真正的帮助。当需要消隐器时,“选项”部分可能有一些东西?
这里有我的 gruntfile:
mochaTest: {
test: {
src: watchFiles.mochaTests,
options: {
reporter: 'spec',
require: ['server.js', 'app/tests/blanket.js']
}
},
coverage: {
src: watchFiles.mochaTests,
options: {
reporter: 'html-cov',
// use the quiet flag to suppress the mocha console output
quiet: true,
// specify a destination file to capture the mocha
// output (the quiet option does not suppress this)
captureFile: 'coverage.html'
}
}
},
这是毯子js包装器:
var path = require('path');
var srcDir = path.join(__dirname, '..');
require('blanket')({
// Only files that match the pattern will be instrumented
pattern: srcDir
});
console.log(srcDir);
src: watchFiles.mochaTests 只是上面的一个变量,用于保存我要运行的测试数组。
【问题讨论】:
标签: node.js gruntjs mocha.js blanket.js