【问题标题】:Karma coverage istanbul does not create folder业力覆盖伊斯坦布尔不创建文件夹
【发布时间】:2018-02-15 17:10:26
【问题描述】:

我正在尝试将代码覆盖率报告器集成到我的业力测试中。

我在我的配置中设置了以下更改:

coverageIstanbulReporter: {
  reports: ['html', 'lcovonly', 'text-summary'],

  // base output directory. If you include %browser% in the path it will be replaced with the karma browser name
  dir: path.join(__dirname, 'coverage'),

  // if using webpack and pre-loaders, work around webpack breaking the source path
  fixWebpackSourcePaths: true,
},

reporters: config.coverage ? ['kjhtml', 'dots', 'coverage-istanbul'] : ['kjhtml', 'dots'],

但不幸的是,它不会创建coverage 文件夹。

这是我的full karma.config.js

我在这里做错了什么?请注意,我正在调用karma start ./karma.conf.js --coverage,甚至在没有配置覆盖参数的情况下进行了检查。

【问题讨论】:

  • 你能在 chrome 控制台上看到测试结果吗?
  • @Xlee 是的,我可以在浏览器中看到测试报告,但没有覆盖

标签: karma-jasmine istanbul karma-coverage


【解决方案1】:

鉴于您在 Chrome 控制台上有 text-summary 输出,并且您已经为报告者指定了 base 目录,您只需要明确告诉报告者哪个子目录应该用于不同的报告类型:

尝试在coverageIstanbulReporter 下添加此条目(来自 repo 的 README):

   // Most reporters accept additional config options. You can pass these through the `report-config` option
  'report-config': {

    // all options available at: https://github.com/istanbuljs/istanbul-reports/blob/590e6b0089f67b723a1fdf57bc7ccc080ff189d7/lib/html/index.js#L135-L137
    html: {
      // outputs the report in ./coverage/html
      subdir: 'html'
    }

  }

【讨论】:

  • 添加了,还是一样 - 不是创建coverage/html
  • 项目根目录没有coverage/文件夹?
  • 不。我尝试手动创建并再次运行,但里面没有html 文件夹。
  • 尽量不要手动创建,看看karma是否先生成coverage/文件夹?
  • 删除它,运行因果报应,没有文件夹
猜你喜欢
  • 1970-01-01
  • 2014-07-11
  • 2014-02-11
  • 2013-12-21
  • 2016-01-22
  • 2017-12-13
  • 1970-01-01
  • 1970-01-01
  • 2019-05-13
相关资源
最近更新 更多