https://github.com/js-devtools/coverage-istanbul-loader
Istanbul code coverage loader for Webpack
https://github.com/js-devtools/coverage-istanbul-loader
code-coverage coverage instrumentation instrumenter istanbul javascript source-maps sourcemap typescript webpack webpack-loader
Last synced: 11 days ago
JSON representation
Istanbul code coverage loader for Webpack
- Host: GitHub
- URL: https://github.com/js-devtools/coverage-istanbul-loader
- Owner: JS-DevTools
- License: mit
- Created: 2019-02-02T11:02:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-09T21:13:53.000Z (over 2 years ago)
- Last Synced: 2025-05-11T18:48:40.009Z (about 1 month ago)
- Topics: code-coverage, coverage, instrumentation, instrumenter, istanbul, javascript, source-maps, sourcemap, typescript, webpack, webpack-loader
- Language: JavaScript
- Homepage: https://jstools.dev/coverage-istanbul-loader/
- Size: 967 KB
- Stars: 33
- Watchers: 3
- Forks: 9
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Istanbul code coverage loader for Webpack
==============================================[](https://github.com/JS-DevTools/coverage-istanbul-loader/actions)
[](https://github.com/JS-DevTools/coverage-istanbul-loader/actions)[](https://coveralls.io/github/JS-DevTools/coverage-istanbul-loader?branch=master)
[](https://david-dm.org/JS-DevTools/coverage-istanbul-loader)[](https://www.npmjs.com/package/@jsdevtools/coverage-istanbul-loader)
[](LICENSE)
[](https://plant.treeware.earth/JS-DevTools/coverage-istanbul-loader)This is a [Webpack loader](https://webpack.js.org/loaders/) that uses [Istanbul](https://istanbul.js.org/) to add code coverage instrumentation to your code. This is especially useful for in-browser testing, in a tool like [Karma](https://karma-runner.github.io/3.0/index.html), where you can use [karma-coverage-istanbul-reporter](https://github.com/mattlewis92/karma-coverage-istanbul-reporter) to output code coverage data in a variety of formats that are supported by services like [Coveralls](https://coveralls.io/) or [Codacy](https://www.codacy.com/).
Coverage Istanbul Loader is based on [Istanbul Instrumenter Loader](https://github.com/webpack-contrib/istanbul-instrumenter-loader), but uses a newer version of the [Istanbul API](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-lib-instrument) and has better support for source maps.
Usage
--------------------------
See [the examples folder](examples) for usage examples for various use cases.- **["hello, world" example](examples/hello-world)**
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](examples/typescript)**
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](examples/karma)**
This example demonstrates using coverage-istanbul-loader with [Karma](https://karma-runner.github.io/3.0/index.html) and [karma-coverage-istanbul-reporter](https://github.com/mattlewis92/karma-coverage-istanbul-reporter) to produce code coverage reports for browser tests.- **[Example with options](examples/options)**
This example demonstrates passing options to coverage-istanbul-loader. The options are passed-on to [istanbul-lib-instrument](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-lib-instrument), so [all the same options](https://github.com/istanbuljs/istanbuljs/blob/25509c7ff31f114e7036a940ed799d6d0548b706/packages/istanbul-lib-instrument/src/instrumenter.js#L11-L33) are supported.Contributing
--------------------------
Contributions, enhancements, and bug-fixes are welcome! [Open an issue](https://github.com/JS-DevTools/coverage-istanbul-loader/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/coverage-istanbul-loader/pulls).#### Building/Testing
To build/test the project locally on your computer:1. __Clone this repo__
`git clone https://github.com/JS-DevTools/coverage-istanbul-loader.git`2. __Install dependencies__
`npm install`3. __Build the code__
`npm run build`4. __Run the tests__
`npm test`License
--------------------------
coverage-istanbul-loader is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.This package is [Treeware](http://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/JS-DevTools/coverage-istanbul-loader) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
Big Thanks To
--------------------------
Thanks to these awesome companies for their support of Open Source developers ❤[](https://travis-ci.com)
[](https://saucelabs.com)
[](https://coveralls.io)