What is karma-coverage-istanbul-reporter?
The karma-coverage-istanbul-reporter is a Karma plugin that uses Istanbul to report code coverage. It provides detailed coverage reports in various formats and integrates seamlessly with Karma, a popular test runner for JavaScript.
What are karma-coverage-istanbul-reporter's main functionalities?
Basic Configuration
This feature allows you to configure the basic settings for the coverage reporter. You can specify the output directory, the types of reports to generate, and whether to fix Webpack source paths.
{"karma.conf.js":{"reporters":["progress","coverage-istanbul"],"coverageIstanbulReporter":{"dir":"coverage/","reports":["html","lcovonly","text-summary"],"fixWebpackSourcePaths":true}}}
Thresholds for Coverage
This feature allows you to set minimum coverage thresholds. If the coverage falls below these thresholds, the test run will fail.
{"karma.conf.js":{"coverageIstanbulReporter":{"thresholds":{"global":{"statements":80,"lines":80,"branches":80,"functions":80}}}}}
Custom Reporters
This feature allows you to generate custom reports in different formats such as HTML, lcov, text-summary, and JSON.
{"karma.conf.js":{"coverageIstanbulReporter":{"reports":["html","lcovonly","text-summary","json"]}}}
Other packages similar to karma-coverage-istanbul-reporter
karma-coverage
karma-coverage is another Karma plugin for code coverage reporting. It uses Istanbul for coverage and provides similar functionalities like generating reports in various formats. However, karma-coverage-istanbul-reporter is more modern and integrates better with Webpack.
karma-remap-istanbul
karma-remap-istanbul is a plugin that remaps coverage information to TypeScript source files. It is useful for projects using TypeScript, but for pure JavaScript projects, karma-coverage-istanbul-reporter is more straightforward.
karma-coverage-istanbul-reporter
A karma reporter that uses the latest istanbul 1.x APIs (with full sourcemap support) to report coverage.
About
This is a reporter only and does not perform the actual instrumentation of your code. Webpack users should use the istanbul-instrumenter-loader and then use this karma reporter to do the actual reporting. See the test config for an e2e example of how to combine them.
Installation
npm install karma-coverage-istanbul-reporter --save-dev
Configuration
const path = require('path');
module.exports = function (config) {
config.set({
plugins: ['karma-coverage-istanbul-reporter'],
reporters: ['coverage-istanbul'],
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'text-summary'],
dir: path.join(__dirname, 'coverage'),
fixWebpackSourcePaths: true,
skipFilesWithNoCoverage: true,
'report-config': {
html: {
subdir: 'html'
}
},
thresholds: {
global: {
statements: 100,
lines: 100,
branches: 100,
functions: 100
},
each: {
statements: 100,
lines: 100,
branches: 100,
functions: 100
}
}
}
});
}
List of reporters and options
Credits
License
MIT