【问题标题】:How to remove dependencies form being included in the Karma test coverage如何从 Karma 测试覆盖中删除依赖项
【发布时间】:2014-06-16 14:51:30
【问题描述】:

Karma 允许您使用 karma conf 文件查看测试覆盖率

reporters
Type: Array
Default: ['progress']
CLI: --reporters progress,growl
Possible Values:
dots
progress
junit
growl
coverage
Description: A list of reporters to use.

我遇到的问题是它在测试覆盖率中包含依赖项。由于我不想测试某些文件,如何将它们排除在测试范围之外。

【问题讨论】:

    标签: karma-runner karma-jasmine test-coverage


    【解决方案1】:

    coveragepreprocessors 属性采用文件规范。

    我的项目结构是:

    /js/
    /lib/
    /tests/
    

    请参见此处的第 4 行,我指示 coverage 仅处理 js/**/*.js。如果我不这样做,它还会包括我的lib/ 和我的tests/ 文件夹。

    coverage: {
      reporters: ['spec', 'coverage'],
      preprocessors: {
        'js/**/*.js': ['coverage']
      },
      coverageReporter: {
        reporters: [
          { type: 'text' },
          { type: 'html', dir: 'coverage/' }
        ]
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-04-07
      • 1970-01-01
      • 1970-01-01
      • 2012-06-17
      • 2014-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      相关资源
      最近更新 更多