karma記錄

Posted 看见了

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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/\'
    }
  });
};

配置项文档

文档

以上是关于karma記錄的主要内容,如果未能解决你的问题,请参考以下文章