This module is unmaintained. Please use deepsweet/isparta-loader
Isparta instrumenter loader for webpack
Instrument JS files with Isparta for subsequent code coverage reporting. Forked from deepsweet/istanbul-instrumenter-loader. Thank you for your work 👍
$ npm i -S isparta-instrumenter-loader
Useful to get work together karma-webpack and karma-coverage. For example:
- karma-webpack config
- karma-coverage config
- replace
karma-coverage
's code instrumenting withisparta-instrumenter-loader
's one:
config.set({
...
files: [
// 'src/**/*.js', << you don't need this anymore
'test/**/*.js'
],
...
preprocessors: {
// 'src/**/*.js': ['coverage'], << and this too
'test/**/*.js': [ 'webpack' ]
},
reporters: [ 'progress', 'coverage' ],
coverageReporter: {
type: 'html',
dir: 'coverage/'
},
...
webpack: {
...
module: {
preLoaders: [ // << add subject as webpack's preloader
{
test: /(\.jsx)|(\.js)$/,
// exclude this dirs from coverage
exclude: /(test|node_modules|bower_components)\//,
loader: 'isparta-instrumenter-loader'
},
],
// other webpack loaders ...
loaders: [ ... ],
},
...
}
});
You can pass config variables to isparta using webpack loader params.
Example (webpack loader config):
{
test: /(.jsx)|(.js)$/,
exclude: /(node_modules|bower_components|Spec)/,
loader: 'isparta-instrumenter',
query: {
babel: {
presets: ['es2015', 'react', 'stage-0']
}
}
This will specify which presets babel should use at instrumenting stage.