Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript grunt代码覆盖率强制执行器不';不要在阈值限制上失败_Javascript_Gruntjs_Code Coverage - Fatal编程技术网

Javascript grunt代码覆盖率强制执行器不';不要在阈值限制上失败

Javascript grunt代码覆盖率强制执行器不';不要在阈值限制上失败,javascript,gruntjs,code-coverage,Javascript,Gruntjs,Code Coverage,我正在运行Jasmine测试和Karma coverage来生成lcov文件。我可以在coverage reports和console中看到,许多JavaScript文件的行覆盖率很差 ------------------------------------|-----------|-----------|-----------|-----------| File | % Stmts |% Branches | % Funcs

我正在运行Jasmine测试和Karma coverage来生成lcov文件。我可以在coverage reports和console中看到,许多JavaScript文件的行覆盖率很差

------------------------------------|-----------|-----------|-----------|-----------|
File                                |   % Stmts |% Branches |   % Funcs |   % Lines |
------------------------------------|-----------|-----------|-----------|-----------|
   ./src/accountDetails/controller\ |      9.09 |       100 |         0 |      9.09 |
      AccountDetailsController.js   |      9.09 |       100 |         0 |      9.09 |
伊斯坦布尔并没有停止grunt进程,所以我添加了grunt代码覆盖率执行器。配置如下所示:

  '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: []
    }
  }
我很确定enforcer正在运行,因为它最初没有找到lcov.info文件。如果我使用--verbose运行enforcer任务,我会看到这样的情况(删除了很多无关的内容,比如它重申了输入选项,看起来是正确的):

因此,我的问题是:

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

我刚刚提交了一个请求,应该可以解决这个问题。希望作者能很快接受请求,并将项目重新发布给npm。

更为神秘的是,执行者在Hudson/Linux上的构建确实失败了,但在Windows 7上没有。因此,尽管构建失败在CI/CD环境中有效,但理想情况下,它在开发人员的机器上也会以同样的方式运行。现在,更神秘的是,我意识到,即使我设置了最小覆盖率,Linux也在崩溃。因此,我将覆盖率设置为5、5、5,但在输出中可以看到:
行:66.67%|函数:100%|分支:100%|>>排除
文件:./src/accountDetails/controller/accountDetails controller.js
>失败的文件:src/accountDetails/controller/accountDetails.js::没有代码覆盖率数据。确保源文件在测试覆盖率(lcov)数据中表示
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.