You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

istanbul-instrumenter-loader

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-instrumenter-loader

Istanbul instrumenter loader for webpack


Version published
Maintainers
3
Created

Package description

What is istanbul-instrumenter-loader?

The 'istanbul-instrumenter-loader' is a webpack loader that instruments JavaScript files with Istanbul coverage, which is useful for generating code coverage reports for your tests.

What are istanbul-instrumenter-loader's main functionalities?

Instrumenting JavaScript files

This feature allows you to instrument JavaScript files for code coverage. The code sample shows how to configure webpack to use 'istanbul-instrumenter-loader' for all JavaScript files in the 'src/' directory.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.resolve('src/'),
        loader: 'istanbul-instrumenter-loader',
        options: { esModules: true }
      }
    ]
  }
};

Using with Babel

This feature demonstrates how to use 'istanbul-instrumenter-loader' in conjunction with 'babel-loader' to transpile and instrument JavaScript files. The code sample shows the configuration for webpack to use both loaders.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.resolve('src/'),
        use: [
          'babel-loader',
          {
            loader: 'istanbul-instrumenter-loader',
            options: { esModules: true }
          }
        ]
      }
    ]
  }
};

Other packages similar to istanbul-instrumenter-loader

Changelog

Source

3.0.0-beta.0 (2017-06-08)

Code Refactoring

  • upgrade to webpack-defaults (#51) (b46a5c8)

BREAKING CHANGES

  • Enforces Webpack standard NodeJS engines range. at the time of merge >= 4.3 < 5.0.0 || >= 5.10.
  • Upgrades loader-utils to 1.1.0 which has a minimum NodeJS version of 4.

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

Readme

Source

npm node deps tests coverage chat

Instrument JS files with istanbul-lib-instrument for subsequent code coverage reporting.

Install

npm install --save-dev istanbul-instrumenter-loader
# or
yarn add --dev istanbul-instrumenter-loader

Usage

References
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:

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

testsContext.keys().forEach(testsContext);

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

componentsContext.keys().forEach(componentsContext);

This file will be the only entry point for Karma.

karma.conf.js
config.set({
    …
    files: [
        'test/index.js'
    ],
    preprocessors: {
        'test/index.js': 'webpack'
    },
    webpack: {
        …
        module: {
            rules: [
                // instrument only testing sources with Istanbul
                {
                    test: /\.js$/,
                    include: path.resolve('src/components/'),
                    loader: 'istanbul-instrumenter-loader'
                }
            ]
        }
        …
    },
    reporters: [ 'progress', 'coverage-istanbul' ],
    coverageIstanbulReporter: {
        reports: [ 'text-summary' ],
        fixWebpackSourcePaths: true
    },
    …
});
Options

The loader supports all options supported by istanbul-lib-instrument.

Contributing

Don't hesitate to create a pull request. Every contribution is appreciated. In development you can start the tests by calling npm test.

Maintainers


Kir Belevich

Juho Vepsäläinen

Joshua Wiens

Kees Kluskens

Sean Larkin

Keywords

FAQs

Package last updated on 08 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc