# karma-coverage

> A Karma plugin. Generate code coverage.

Latest version **2.2.1** (published 2023-06-23) · MIT license · 2.2M weekly downloads

## Install

```sh
npm install karma-coverage
pnpm add karma-coverage
yarn add karma-coverage
bun add karma-coverage
```

## Health

**Score 53/100 (C)** — status: abandoned.

Positive: high downloads; has types package; no vulnerabilities; high quality score.

Warnings: no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2023-06-23 |
| First published | 2013-03-19 |
| Weekly downloads | 2.2M |
| License | MIT |
| TypeScript types | separate (@types/karma-coverage) |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 6 |
| Unpacked size | 58.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 771 |
| Author | SATO taichi |
| Maintainers | dignifiedquire, zzo, vojtajina, karmarunnerbot |
| Keywords | karma-plugin, karma-preprocessor, karma-reporter, coverage, istanbul |

## Links

- npm: https://www.npmjs.com/package/karma-coverage
- Repository: https://github.com/karma-runner/karma-coverage
- Homepage: https://github.com/karma-runner/karma-coverage#readme
- Issues: https://github.com/karma-runner/karma-coverage/issues
- npm.io page: https://npm.io/package/karma-coverage

## Dependencies (6)

- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4
- [istanbul-reports](https://npm.io/package/istanbul-reports.md) ^3.0.5
- [istanbul-lib-report](https://npm.io/package/istanbul-lib-report.md) ^3.0.0
- [istanbul-lib-coverage](https://npm.io/package/istanbul-lib-coverage.md) ^3.2.0
- [istanbul-lib-instrument](https://npm.io/package/istanbul-lib-instrument.md) ^5.1.0
- [istanbul-lib-source-maps](https://npm.io/package/istanbul-lib-source-maps.md) ^4.0.1

## Recent versions

- 2.2.1 (latest) — 2023-06-23
- 2.2.0 — 2022-02-10
- 2.1.1 — 2022-02-05
- 2.1.0 — 2021-12-01
- 2.0.3 — 2020-07-24
- 2.0.2 — 2020-04-13
- 2.0.1 — 2019-08-20
- 2.0.0 — 2019-08-20
- 1.1.2 — 2018-05-03
- 1.1.1 — 2016-07-23
- 1.1.0 — 2016-07-07
- 1.0.0 — 2016-05-04
- 0.5.5 — 2016-03-07
- 0.5.4 — 2016-03-03
- 0.5.3 — 2015-10-20
- … 27 more at https://npm.io/package/karma-coverage/versions

## README

# karma-coverage

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-coverage)
 [![npm version](https://img.shields.io/npm/v/karma-coverage.svg?style=flat-square)](https://www.npmjs.com/package/karma-coverage) [![npm downloads](https://img.shields.io/npm/dm/karma-coverage.svg?style=flat-square)](https://www.npmjs.com/package/karma-coverage)

[![Build Status](https://img.shields.io/travis/karma-runner/karma-coverage/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-coverage) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-coverage.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-coverage) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-coverage.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-coverage#info=devDependencies)

> Generate code coverage using [Istanbul].

## Installation

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

```bash
npm install karma karma-coverage --save-dev
```

## Configuration

For configuration details see [docs/configuration](docs/configuration.md).

## Examples

### Basic

```javascript
// 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](http://coffeescript.org/)
see [examples/coffee](examples/coffee). For an example of how to use with
CoffeeScript and the RequireJS module loader, see
[examples/coffee-requirejs](examples/coffee-requirejs) (and also see
the `useJSExtensionForCoffeeScript` option in
[docs/configuration.md](docs/configuration.md)).

### Advanced, multiple reporters

```javascript
// 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.

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

----

For more information on Karma see the [homepage].


[homepage]: https://karma-runner.github.io
[Istanbul]: https://istanbul.js.org

---
_Source: https://npm.io/package/karma-coverage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
