我正在运行Jasmine测试和Karma覆盖以生成lcov文件。我可以在覆盖率报告和控制台中看到,许多JavaScript文件的线路覆盖率很低。
------------------------------------|-----------|-----------|-----------|-----------|
File | % Stmts |% Branches | % Funcs | % Lines |
------------------------------------|-----------|-----------|-----------|-----------|
./src/accountDetails/controller\ | 9.09 | 100 | 0 | 9.09 |
AccountDetailsController.js | 9.09 | 100 | 0 | 9.09 |
伊斯坦布尔并未停止咕噜声,因此我添加了grunt-code-coverage-enforcer。配置如下所示:
'code-coverage-enforcer': { /* doesn't seem to work either */
options: {
lcovfile: "build/lcov/PhantomJS 1.9.7 (Windows 7)/lcov.info",
lines: 99,
functions: 99,
branches: 99,
src: "src",
includes: ['src/**/*.js'],
excludes: []
}
}
我非常确定执行器正在运行,因为最初它没有找到lcov.info文件。如果我使用--verbose运行强制执行任务,我会看到这个(删除了很多无关的东西,比如它重复输入选项,看起来是正确的):
Reading the lcov file ....
Processing File:build/lcov/PhantomJS 1.9.7 (Windows 7)/lcov.info
Checking if file exists ... build/lcov/PhantomJS 1.9.7 (Windows 7)/lcov.info
processing callback with [
{
"file": "./src/accountDetails/controller/AccountDetailsController.js",
"lines": {
"found": 11,
"hit": 1
},
"functions": {
"hit": 0,
"found": 3
},
"branches": {
"hit": 0,
"found": 0
}
}
]
------------------------------------------------------------------
Scanning folder for files
------------------------------------------------------------------
Collecting directory:src\accountDetails\controller
------------------------------------------------------------------
Threshold configuration: lines:99%, functions:99%, branches:99%
------------------------------------------------------------------
File:./src/accountDetails/controller/AccountDetailsController.js
lines:9.09% | functions:100% | branches:100% | >> EXCLUDED
Done, without errors.
所以我的问题是:
答案 0 :(得分:0)
我刚刚在https://github.com/tapasvimoturu/grunt-code-coverage-enforcer/pull/2提交了拉取请求,应该解决这个问题。希望作者尽快接受请求并将项目重新发布到npm。