karma-runner/karma-coverage


A Karma plugin. Generate code coverage.

License: Other

Language: CoffeeScript


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.

Project Statistics

Sourcerank 20
Repository Size 217 KB
Stars 726
Forks 229
Watchers 32
Open issues 101
Dependencies 621
Contributors 53
Tags 35
Created
Last updated
Last pushed

Top Contributors See all

Friedel Ziegelmayer Vojta Jina Aymeric Beaumet johnjbarton Mark Trostler Julen Garcia Leunda Tim Kang Maksim Ryzhikov Nick Malaguti Nico Jansen Tanguy Krotoff Allen Matt Winchester Douglas Duteil Wei Kin Huang Kyle Welsby Dmitry Petrov Michael Noack Yusuke Suzuki Julie Ralph

Packages Referencing this Repo

karma-coverage-0.11
A Karma plugin. Generate code coverage. Updating dependency to karma 0.11
Latest release 0.1.1 - Published - 726 stars
karma-coverage
A Karma plugin. Generate code coverage.
Latest release 2.0.1 - Updated - 726 stars
karma-coverage-blamer
A Karma plugin. Generate code coverage.
Latest release 0.2.8 - Updated - 726 stars
karma-coverage-blamer1
A Karma plugin. Generate code coverage.
Latest release 0.2.8 - Published - 726 stars
karma-coverage-es6
A Karma plugin. Generate code coverage with support of ES6
Latest release 0.2.7 - Published - 726 stars
karma-gvcoverage
A Karma plugin. Generate code coverage.
Latest release 0.2.1 - Published - 726 stars
karma-police
A Karma plugin. Generate code coverage.
Latest release 0.2.8 - Updated - 726 stars
org.webjars.npm:karma-coverage
WebJar for karma-coverage
Latest release 1.0.0 - Updated - 726 stars
karma-coverage-lynx
A Karma plugin. Generate code coverage.
Latest release 0.2.7 - Updated - 726 stars

Recent Tags See all

v2.0.1 August 20, 2019
v2.0.0 August 20, 2019
v1.1.2 May 03, 2018
v1.1.1 July 23, 2016
v1.1.0 July 07, 2016
v1.0.0 May 04, 2016
v0.5.5 March 07, 2016
v0.5.4 March 03, 2016
v0.5.3 October 20, 2015
v0.5.2 September 08, 2015
v0.5.1 August 28, 2015
v0.5.0 August 06, 2015
v0.4.2 June 12, 2015
v0.4.1 June 09, 2015
v0.4.0 June 09, 2015

Interesting Forks See all

seeq12/karma-coverage
A Karma plugin. Generate code coverage.
CoffeeScript - MIT - Last pushed - 3 stars
kylewelsby/karma-coverage
A Karma plugin. Generate code coverage.
CoffeeScript - MIT - Last pushed - 2 stars - 4 forks
danielflower/karma-js-coverage
A Karma plugin. Generate code coverage.
JavaScript - MIT - Last pushed - 1 stars - 1 forks
HBOCodeLabs/karma-coverage
A Karma plugin. Generate code coverage.
CoffeeScript - MIT - Last pushed - 1 stars
Spote/karma-coverage
A Karma plugin. Generate code coverage.
CoffeeScript - MIT - Last pushed - 1 stars - 2 forks

Something wrong with this page? Make a suggestion

Last synced: 2019-08-20 23:51:14 UTC

Login to resync this repository