karma-coverage

A Karma plugin. Generate code coverage.

  • 所有者: karma-runner/karma-coverage
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

karma-coverage

js-standard-style
npm version npm downloads

Build Status Dependency Status devDependency Status

Generate code coverage using Istanbul.

Installation

The easiest way is to install karma-coverage as a devDependency,
by running

npm install karma karma-coverage --save-dev

Configuration

For configuration details see docs/configuration.

Examples

Basic

// 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/'
    }
  });
};

CoffeeScript

For an example on how to use with CoffeeScript
see examples/coffee. For an example of how to use with
CoffeeScript and the RequireJS module loader, see
examples/coffee-requirejs (and also see
the useJSExtensionForCoffeeScript option in
docs/configuration.md).

Advanced, multiple reporters

// karma.conf.js
module.exports = function(config) {
  config.set({
    files: [
      'src/**/*.js',
      'test/**/*.js'
    ],
    reporters: ['progress', 'coverage'],
    preprocessors: {
      'src/**/*.js': ['coverage']
    },
    coverageReporter: {
      // specify a common output directory
      dir: 'build/reports/coverage',
      reporters: [
        // reporters not supporting the `file` property
        { type: 'html', subdir: 'report-html' },
        { type: 'lcov', subdir: 'report-lcov' },
        // reporters supporting the `file` property, use `subdir` to directly
        // output them in the `dir` directory
        { type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
        { type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
        { type: 'teamcity', subdir: '.', file: 'teamcity.txt' },
        { type: 'text', subdir: '.', file: 'text.txt' },
        { type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
      ]
    }
  });
};

FAQ

Don't minify instrumenter output

When using the istanbul instrumenter (default), you can disable code compaction by adding the following to your configuration.

// karma.conf.js
module.exports = function(config) {
  config.set({
    coverageReporter: {
      instrumenterOptions: {
        istanbul: { noCompact: true }
      }
    }
  });
};

For more information on Karma see the homepage.

主要指標

概覽
名稱與所有者karma-runner/karma-coverage
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2013-02-28 07:44:44
推送於2024-10-09 18:56:48
最后一次提交2023-06-23 09:32:56
發布數41
最新版本名稱v2.2.1 (發布於 )
第一版名稱v0.0.2 (發布於 )
用户参与
星數772
關注者數21
派生數247
提交數274
已啟用問題?
問題數264
打開的問題數116
拉請求數91
打開的拉請求數21
關閉的拉請求數129
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?