@stackline/karma-coverage
v1.0.2
Published
A Karma plugin. Generate code coverage.
Maintainers
Readme
@stackline/karma-coverage
A Karma plugin. Generate code coverage.
Documentation | npm | Issues | Repository
Current package version: 1.0.2
Why this package?
@stackline/karma-coverage is the Stackline-maintained distribution of [email protected]. It is an independent continuation of karma-coverage; original authors and licenses remain credited below.
Compatibility
| Item | Value |
| :--- | :--- |
| Package | @stackline/[email protected] |
| API target | [email protected] |
| Supported Node.js | >=10.0.0 |
| License | MIT |
| Main entry | lib/index.js |
| Runtime dependencies | istanbul-lib-coverage, istanbul-lib-instrument, istanbul-lib-report, istanbul-lib-source-maps, istanbul-reports, minimatch |
Installation
npm install @stackline/karma-coveragePreserve existing imports and plugin resolution with an npm alias:
npm install karma-coverage@npm:@stackline/karma-coverageUsage and API reference
karma-coverage
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-devConfiguration
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.
Credits and original authors
- Original project: karma-coverage.
- SATO taichi.
- dignifiedquire.
- Friedel Ziegelmayer.
- Aymeric Beaumet.
- Anton.
- johnjbarton.
- dependabot[bot].
- Jonathan Ginsburg.
- Mark Ethan Trostler.
- Tim Kang.
- hicom150.
- semantic-release-bot.
- Anton Shchekota.
- Maksim Ryzhikov.
- Nick Malaguti.
- Mark Trostler.
- nicojs.
- Allen Bierbaum.
- Douglas Duteil.
- Julen Garcia Leunda.
- Matt Winchester.
- Srinivas Dhanwada.
- Tanguy Krotoff.
- Wei Kin Huang.
- Yaroslav Admin.
- Adam Heath.
- Andrew Lane.
- Chris Gladd.
- Clayton Watts.
- Dan Watling.
- Darryl Pogue.
- Diogo Nicoleti.
- Dmitry Petrov.
- Francesco Borzì.
- Greg Varsanyi.
- Ian Rufus.
- James Talmage.
- Joseph Connolly.
- Joshua Appelman.
- Julie.
- Kyle Welsby.
- Lloyd Smith II.
- Maciej Rzepiński.
- Marceli.no.
- Matt Lewis.
- Michael Noack.
- Michael Stramel.
- Nick Matantsev.
- Petar Manev.
- Robin Böhm.
- Ron Derksen.
- Ruben Bridgewater.
- Sahat Yalkabov.
- Tanjo, Hiroyuki.
- Taylor Hakes.
- Taylor McGann.
- Tim van der Lippe.
- Timo Tijhof.
- Tom Kirkpatrick.
- Tyler Waters.
- Vincent Lemeunier.
- Yusuke Suzuki.
- abbr.
- aprooks.
- carlos.
- fbergr.
- piecyk.
- terussell85.
- Copyright (C) 2011-2013 Google, Inc.
- Stackline maintenance: Alexandro Paixao Marques and Stackline contributors.
Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.
License
MIT. See the license and notice files in the repository.
Community and Links
Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.
