Gathering detailed insights and metrics for babel-plugin-istanbul
Gathering detailed insights and metrics for babel-plugin-istanbul
Gathering detailed insights and metrics for babel-plugin-istanbul
Gathering detailed insights and metrics for babel-plugin-istanbul
vite-plugin-istanbul
vite-plugin-istanbul ========================== [](https://www.codacy.com/gh/iFaxity/vite-plugin-istanbul/dashboard) [
Total Downloads
5,299,186,227
Last Day
1,671,662
Last Week
29,239,261
Last Month
127,484,384
Last Year
1,296,183,475
BSD-3-Clause License
644 Stars
129 Commits
77 Forks
14 Watchers
3 Branches
32 Contributors
Updated on Jun 20, 2025
Minified
Minified + Gzipped
Latest Version
7.0.0
Package Id
babel-plugin-istanbul@7.0.0
Unpacked Size
25.82 kB
Size
7.82 kB
File Count
6
NPM Version
6.14.18
Node Version
14.21.3
Published on
Jul 05, 2024
Cumulative downloads
Total Downloads
Last Day
-12%
1,671,662
Compared to previous day
Last Week
-9.2%
29,239,261
Compared to previous week
Last Month
5.5%
127,484,384
Compared to previous month
Last Year
13.9%
1,296,183,475
Compared to previous year
Having problems? want to contribute? join our community slack.
A Babel plugin that instruments your code with Istanbul coverage. It can instantly be used with karma-coverage and mocha on Node.js (through nyc).
Note: This plugin does not generate any report or save any data to any file; it only adds instrumenting code to your JavaScript source code. To integrate with testing tools, please see the Integrations section.
Install it:
npm install --save-dev babel-plugin-istanbul
Add it to .babelrc
in test mode:
1{ 2 "env": { 3 "test": { 4 "plugins": [ "istanbul" ] 5 } 6 } 7}
Optionally, use cross-env to set
NODE_ENV=test
:
1{ 2 "scripts": { 3 "test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.js" 4 } 5}
It just works with Karma. First, make sure that the code is already transpiled by Babel (either using karma-babel-preprocessor
, karma-webpack
, or karma-browserify
). Then, simply set up karma-coverage according to the docs, but don’t add the coverage
preprocessor. This plugin has already instrumented your code, and Karma should pick it up automatically.
It has been tested with bemusic/bemuse project, which contains ~2400 statements.
Configure Mocha to transpile JavaScript code using Babel, then you can run your tests with nyc
, which will collect all the coverage report.
babel-plugin-istanbul respects the include
/exclude
configuration options from nyc,
but you also need to configure NYC not to instrument your code by adding these settings in your package.json
:
1 "nyc": { 2 "sourceMap": false, 3 "instrument": false 4 },
You don't want to cover your test files as this will skew your coverage results. You can configure this by providing plugin options matching nyc's exclude
/include
rules:
1{ 2 "env": { 3 "test": { 4 "plugins": [ 5 ["istanbul", { 6 "exclude": [ 7 "**/*.spec.js" 8 ] 9 }] 10 ] 11 } 12 } 13}
If you don't provide options in your Babel config, the plugin will look for exclude
/include
config under an "nyc"
key in package.json
.
You can also use istanbul's ignore hints to specify specific lines of code to skip instrumenting.
By default, this plugin will pick up inline source maps and attach them to the instrumented code such that code coverage can be remapped back to the original source, even for multi-step build processes. This can be memory intensive. Set useInlineSourceMaps
to prevent this behavior.
1{ 2 "env": { 3 "test": { 4 "plugins": [ 5 ["istanbul", { 6 "useInlineSourceMaps": false 7 }] 8 ] 9 } 10 } 11}
If you're instrumenting code programatically, you can pass a source map explicitly.
1import babelPluginIstanbul from 'babel-plugin-istanbul'; 2 3function instrument(sourceCode, sourceMap, filename) { 4 return babel.transform(sourceCode, { 5 filename, 6 plugins: [ 7 [babelPluginIstanbul, { 8 inputSourceMap: sourceMap 9 }] 10 ] 11 }) 12}
The approach used in babel-plugin-istanbul
was inspired by Thai Pangsakulyanont's original library babel-plugin-__coverage__
.
babel-plugin-istanbul
for enterpriseAvailable as part of the Tidelift Subscription.
The maintainers of babel-plugin-istanbul
and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 6/25 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More