babel-plugin-istanbul
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@babel/helper-plugin-utils | 7.24.5 | 127.43 kB | MIT | prod | |
@istanbuljs/load-nyc-config | 1.1.0 | 4.23 kB | ISC | prod | |
@istanbuljs/schema | 0.1.3 | 5.3 kB | MIT | prod | |
istanbul-lib-instrument | 5.2.1 | 15.97 kB | BSD-3-Clause | prod | 1 1 |
test-exclude | 6.0.0 | 6.75 kB | ISC | prod |
The babel-plugin-istanbul is a powerful tool that adds Istanbul instrumentation to your ES6 code. It is a Babel plugin that integrates seamlessly with your code to provide coverage metrics. This plugin does not generate any output or save any data to a file; it simply adds instrumentation to your JavaScript source code. This makes it perfect for use with toolsets like Karma-coverage and mocha on Node.js via nyc, where it can instantly elevate your testing capabilities.
To use the babel-plugin-istanbul, you first need to install it using npm by running npm install --save-dev babel-plugin-istanbul
. Once installed, you need to add it to your .babelrc
file in testing mode. This is done with the following code:
{
"env": {
"test": {
"plugins": [ "istanbul" ]
}
}
}
Alongside this, you can optionally use cross-env to set NODE_ENV=test
. An example of this type of set-up is:
{
"scripts": {
"test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.js"
}
}
Ultimately, integrating babel-plugin-istanbul into your testing environment requires strategic placement in your Babel and environment scripts.
Complete details for babel-plugin-istanbul are available in the documentation on the babel-plugin-istanbul GitHub page. The repository provides all the necessary information for understanding, installing, integrating, and troubleshooting the babael-plugin-istanbul tool. Furthermore, it defines how to use the plugin with other tools, how to ignore files from coverage reports, how to manage source maps and more. You can also find frequently asked questions, change logs, and contributing guidelines in this detailed documentation.