rollup-plugin-istanbul
Seamless integration between Rollup and Istanbul.
Why?
If you're using Rollup to generate a standalone bundle you will probably need also to bundle your tests before running them, and if you want the code coverage report, you will need to instrument the program files before the bundle is generated to avoid instrumenting also the code of the test files.
That is the reason why rollup-plugin-istanbul exists.
Installation
npm install --save-dev rollup-plugin-istanbul
Usage
;;
Options
All options are optional.
include
Can be a minimatch pattern or an array of minimatch patterns. If is omitted or of zero length, files should be included by default; otherwise they should only be included if the ID matches one of the patterns.
exclude
Can be a minimatch pattern or an array of minimatch patterns. Files to exclude, commonly the test files.
extensions
Array of strings that specifies the file extensions to process. default: ['js']
compact
generate compact code. default: true
sourceMap
produce a source map for the instrumented code. default: true
instrumenterConfig
An object of options that will be passed to the instrumenter.
Default value:
esModules: true compact: true produceSourceMap: true
More info about options.
instrumenter
Can be a replacement for the istanbul library, for example isparta. It should implement the same API as istanbul.
Other usage options
rollup-plugin-istanbul
can be used with karma or other test runners that allow preprocessors. Here you can see how to implement it with Karma with the help of the karma-rollup-preprocessor and karma-coverage:
// karma.conf.jsvar istanbul = ; module { config;};
Going further, this is how you can implement it when you are using babel because you are writing ES2015 code:
// karma.conf.js var babelrc = default babel = istanbul = ; module { config;};
Example of implementation with Mocha provided by @piuccio: https://github.com/artberri/rollup-plugin-istanbul/issues/11