Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
karma-coverage-istanbul-reporter
Advanced tools
A karma reporter that uses the latest istanbul 1.x APIs (with full sourcemap support) to report coverage.
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.
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"]}}}
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 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.
A karma reporter that uses the latest istanbul 1.x APIs (with full sourcemap support) to report coverage.
This is a reporter only and does not perform the actual instrumentation of your code. Babel users should use the istanbul babel plugin to instrument your code and webpack + typescript 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.
npm install karma-coverage-istanbul-reporter --save-dev
// karma.conf.js
const path = require('path');
module.exports = function(config) {
config.set({
// ... rest of karma config
// anything named karma-* is normally auto included so you probably dont need this
plugins: ['karma-coverage-istanbul-reporter'],
reporters: ['coverage-istanbul'],
// any of these options are valid: https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-api/lib/config.js#L33-L39
coverageIstanbulReporter: {
// reports can be any that are listed here: https://github.com/istanbuljs/istanbuljs/tree/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib
reports: ['html', 'lcovonly', 'text-summary'],
// base output directory. If you include %browser% in the path it will be replaced with the karma browser name
dir: path.join(__dirname, 'coverage'),
// Combines coverage information from multiple browsers into one report rather than outputting a report
// for each browser.
combineBrowserReports: true,
// if using webpack and pre-loaders, work around webpack breaking the source path
fixWebpackSourcePaths: true,
// stop istanbul outputting messages like `File [${filename}] ignored, nothing could be mapped`
skipFilesWithNoCoverage: true,
// Most reporters accept additional config options. You can pass these through the `report-config` option
'report-config': {
// all options available at: https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/html/index.js#L135-L137
html: {
// outputs the report in ./coverage/html
subdir: 'html'
}
},
// enforce percentage thresholds
// anything under these percentages will cause karma to fail with an exit code of 1 if not running in watch mode
thresholds: {
emitWarning: false, // set to `true` to not fail the test command when thresholds are not met
// thresholds for all files
global: {
statements: 100,
lines: 100,
branches: 100,
functions: 100
},
// thresholds per file
each: {
statements: 100,
lines: 100,
branches: 100,
functions: 100,
overrides: {
'baz/component/**/*.js': {
statements: 98
}
}
}
},
verbose: true // output config used by istanbul for debugging
}
});
};
MIT
FAQs
A karma reporter that uses the latest istanbul 1.x APIs (with full sourcemap support) to report coverage.
The npm package karma-coverage-istanbul-reporter receives a total of 594,805 weekly downloads. As such, karma-coverage-istanbul-reporter popularity was classified as popular.
We found that karma-coverage-istanbul-reporter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.