This module is unmaintained. Please use https://github.com/deepsweet/isparta-loader
HTML JavaScript
Clone or download
Pull request Compare This branch is 31 commits ahead, 67 commits behind webpack-contrib:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
.editorconfig
.eslintrc
.gitignore
.jscsrc
.npmignore
.travis.yml
History.md
README.md
index.js
package.json

README.md

⚠️ ⚠️ ❗️ DEPRECATED ❗️ ⚠️ ⚠️

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 👍

Install

$ npm i -S isparta-instrumenter-loader

Usage

Useful to get work together karma-webpack and karma-coverage. For example:

  1. karma-webpack config
  2. karma-coverage config
  3. replace karma-coverage's code instrumenting with isparta-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: [ ... ],
        },
        ...
    }
});

Documentation: Using loaders.

Passing options to isparta

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.

License

WTFPL