Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
istanbul-instrumenter-loader
Advanced tools
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.
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 }
}
]
}
]
}
};
The 'babel-plugin-istanbul' is a Babel plugin that instruments your code with Istanbul coverage. It is similar to 'istanbul-instrumenter-loader' but is used as a Babel plugin instead of a webpack loader. This can be more convenient if you are already using Babel for transpilation.
The 'nyc' package is a command-line interface for Istanbul. It provides a more comprehensive solution for code coverage, including running tests and generating reports. Unlike 'istanbul-instrumenter-loader', which is a webpack loader, 'nyc' can be used independently of webpack.
Instrument JS files with Istanbul for subsequent code coverage reporting.
"Forked" from unfold/istanbul-instrument-loader.
npm i -S istanbul-instrumenter-loader
Useful to get work together karma-webpack and karma-coverage. For example:
karma-coverage
's code instrumenting with istanbul-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 istanbul-instrumenter-loader as webpack's preloader
test: /\.js$/,
exclude: /(test|node_modules|bower_components)\//,
loader: 'istanbul-instrumenter-loader'
} ],
loaders: [ ... ]
},
...
}
});
FAQs
Istanbul instrumenter loader for webpack
The npm package istanbul-instrumenter-loader receives a total of 0 weekly downloads. As such, istanbul-instrumenter-loader popularity was classified as not popular.
We found that istanbul-instrumenter-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.