【问题标题】:Want karma code coverage html without writing --code-coverage想要业力代码覆盖率html而不写--code-coverage
【发布时间】:2018-03-27 18:44:16
【问题描述】:

实际问题是 ng 命令不起作用,因为我使用的是 Windows 7。让我们忘记 ng 命令问题。

所以我像 npm run ng test 一样运行。

如果我写 npm run ng test --code-coverage = true 它将仅作为 ng test 运行。所以我需要配置代码覆盖率(生成报告并创建一个包含 HTML 文件的目录)在 karma 配置文件中(如果可能)。

Karma.conf.js:

module.exports = function (config) 
{
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'], // ChromeHeadless
    singleRun: false
  });
};

【问题讨论】:

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


    【解决方案1】:

    npm test -- --cc一样运行

    之后——你传递的任何东西都会被 ng 命令接受。

    【讨论】:

      猜你喜欢
      • 2016-03-21
      • 2020-10-05
      • 2015-10-06
      • 2018-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      相关资源
      最近更新 更多