Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including isparta-loader with all npm packages installed. Try it out:

var ispartaLoader = require("isparta-loader")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

isparta-loader v2.0.0

isparta instrumenter loader for webpack

isparta instrumenter loader for webpack

npm deps

Instrument Babel code with isparta for subsequent code coverage reporting.


$ npm i -D isparta-loader



Project structure

Let's say you have the following:

├── src/
│   └── components/
│       ├── bar/
│       │   └── index.js
│       └── foo/
│           └── index.js
└── test/
    └── src/
        └── components/
            └── foo/
                └── index.js

To create a code coverage report for all components (even for those for which you have no tests yet) you have to require all the 1) sources and 2) tests. Something like it's described in "alternative usage" of karma-webpack:


// require all `test/components/**/index.js`
const testsContext = require.context('./src/components/', true, /index\.js$/);


// require all `src/components/**/index.js`
const componentsContext = require.context('../src/components/', true, /index\.js$/);


This file will be the only entry point for Karma:


    files: [
    preprocessors: {
        'test/index.js': 'webpack'
    webpack: {
        module: {
            preLoaders: [
                // transpile all files except testing sources with babel as usual
                    test: /\.js$/,
                    exclude: [
                    loader: 'babel'
                // transpile and instrument only testing sources with isparta
                    test: /\.js$/,
                    include: path.resolve('src/components/'),
                    loader: 'isparta'
    reporters: [ 'progress', 'coverage' ],
    coverageReporter: {
        type: 'text'



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free