Grunt-code-coverage-enforcer在阈值限制下不会失败

grunt-code-coverage-enforcer doesn't fail on threshhold limits

本文关键字:失败 阈值 Grunt-code-coverage-enforcer      更新时间:2023-09-26

我正在运行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 |

Istanbul没有停止grunt进程,所以我添加了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.

我的问题是:

  • 正确吗?
  • 输出中的>> EXCLUDED是关于什么的?
  • 这个强制执行任务应该使我的构建过程失败吗?
  • 我可以让它在我的构建过程中失败(或者我误解了JavaScript应用程序中的代码覆盖强制是为了什么)????????????

我刚刚在https://github.com/tapasvimoturu/grunt-code-coverage-enforcer/pull/2提交了一个拉请求,应该解决这个问题。希望作者能尽快接受请求,并将项目重新发布到npm。