
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@jsdevtools/coverage-istanbul-loader
Advanced tools
A Webpack loader that uses Istanbul to add code coverage instrumentation
@jsdevtools/coverage-istanbul-loader is a Webpack loader that instruments your code with Istanbul coverage when running tests. It is typically used in conjunction with test runners like Mocha, Karma, or Jest to generate code coverage reports.
Instrumenting Code for Coverage
This feature allows you to instrument your JavaScript code for coverage. The loader processes files matching the specified test pattern (in this case, .js files in the src directory) and instruments them using Istanbul.
module.exports = {
module: {
rules: [
{
test: /\.js$/,
include: /src/,
loader: '@jsdevtools/coverage-istanbul-loader'
}
]
}
};
Combining with Other Loaders
This feature demonstrates how to combine @jsdevtools/coverage-istanbul-loader with other loaders, such as babel-loader. This is useful for transpiling ES6+ code and then instrumenting it for coverage.
module.exports = {
module: {
rules: [
{
test: /\.js$/,
include: /src/,
use: [
'babel-loader',
'@jsdevtools/coverage-istanbul-loader'
]
}
]
}
};
istanbul-instrumenter-loader is another Webpack loader for instrumenting JavaScript files with Istanbul coverage. It is similar to @jsdevtools/coverage-istanbul-loader but is an older package and may not have the latest updates and features.
babel-plugin-istanbul is a Babel plugin that instruments your code with Istanbul coverage. Unlike @jsdevtools/coverage-istanbul-loader, which is a Webpack loader, this package integrates directly with Babel, making it a good choice if you are already using Babel for transpilation.
karma-coverage-istanbul-reporter is a Karma reporter that uses Istanbul to generate code coverage reports. It is specifically designed to work with the Karma test runner, whereas @jsdevtools/coverage-istanbul-loader is more general-purpose and can be used with various test runners.
This is a Webpack loader that uses Istanbul to add code coverage instrumentation to your code. This is especially useful for in-browser testing, in a tool like Karma, where you can use karma-coverage-istanbul-reporter to output code coverage data in a variety of formats that are supported by services like Coveralls or Codacy.
Coverage Istanbul Loader is based on Istanbul Instrumenter Loader, but uses a newer version of the Istanbul API and has better support for source maps.
See the examples folder for usage examples for various use cases.
"hello, world" example
This is the most simplistic example. It just uses coverage-istanbul-loader with its default options to produce an output bundle that contains code coverage instrumentation.
TypeScript example
This example demonstrates using coverage-istanbul-loader with transpiled code. It correctly maps the instrumented JavaScript code back to the original TypeScript source code.
Karma example
This example demonstrates using coverage-istanbul-loader with Karma and karma-coverage-istanbul-reporter to produce code coverage reports for browser tests.
Example with options
This example demonstrates passing options to coverage-istanbul-loader. The options are passed-on to istanbul-lib-instrument, so all the same options are supported.
Contributions, enhancements, and bug-fixes are welcome! Open an issue on GitHub and submit a pull request.
To build/test the project locally on your computer:
Clone this repo
git clone https://github.com/JS-DevTools/coverage-istanbul-loader.git
Install dependencies
npm install
Build the code
npm run build
Run the tests
npm test
coverage-istanbul-loader is 100% free and open-source, under the MIT license. Use it however you want.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
Thanks to these awesome companies for their support of Open Source developers ❤
FAQs
A Webpack loader that uses Istanbul to add code coverage instrumentation
The npm package @jsdevtools/coverage-istanbul-loader receives a total of 0 weekly downloads. As such, @jsdevtools/coverage-istanbul-loader popularity was classified as not popular.
We found that @jsdevtools/coverage-istanbul-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.