博客 / 詳情

返回

karma記錄

代碼覆蓋率

使用Istanbul生成代碼覆蓋率。

安裝

npm install karma karma-coverage --save-dev

例子

// karma.conf.js
module.exports = function(config) {
  config.set({
    files: [
      'src/**/*.js',
      'test/**/*.js'
    ],
 
    // coverage reporter generates the coverage
    reporters: ['progress', 'coverage'],
 
    preprocessors: {
      // source files, that you wanna generate coverage for
      // do not include tests or libraries
      // (these files will be instrumented by Istanbul)
      'src/**/*.js': ['coverage']
    },
 
    // optionally, configure the reporter
    coverageReporter: {
      type : 'html',
      dir : 'coverage/'
    }
  });
};

配置項文檔

文檔

user avatar sunmengyuan 頭像
1 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.