Registry / testing / babel-plugin-istanbul

babel-plugin-istanbul

JSON →
library8.0.0jsnpmunverified

Babel plugin that instruments JavaScript code with Istanbul coverage. Version 8.0.0 (stable) requires Node >=18 and Babel 7/8. It automatically detects test files via nyc's exclude/include patterns and respects inline source maps. Unlike manual instrumentation, this plugin integrates seamlessly with existing Babel pipelines and tools like karma-coverage and nyc. Released as part of the istanbuljs project with regular updates and LTS support. Key differentiator: zero-config setup with nyc and Karma, and no need for separate coverage preprocessor.

npm install babel-plugin-istanbul
INSTALL
IMPORT
SIG · BABEL-PLUGIN-ISTAN
B
babel-plugin-istanbul
testingjavascriptv8.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import babelPluginIstanbul from 'babel-plugin-istanbul'
const babelPluginIstanbul = require('babel-plugin-istanbul')
Default import works in ESM environments. For older Node versions, use require but ensure Babel is configured to handle it.
babelPluginIstanbul
const babelPluginIstanbul = require('babel-plugin-istanbul');
const { default: babelPluginIstanbul } = require('babel-plugin-istanbul');
CommonJS usage: direct require works; no need to destructure default.
plugin configuration
plugins: ['istanbul'] or plugins: [['istanbul', { exclude: ['**/*.spec.js'] }]]
plugins: ['babel-plugin-istanbul']
In .babelrc or babel.config.js, use the shorthand name 'istanbul' not the full package name.

Shows minimal setup to instrument code with babel-plugin-istanbul: install, configure .babelrc for test env, configure nyc to skip own instrumentation, and run tests with nyc.

// Install: npm install --save-dev babel-plugin-istanbul // In .babelrc: { "env": { "test": { "plugins": ["istanbul"] } } } // In package.json, configure nyc to not re-instrument: "nyc": { "sourceMap": false, "instrument": false } // Run tests: npx nyc --reporter=lcov --reporter=text npx mocha test/*.js
Debug
Known issues
breakingNode 8 and 10 dropped
fix
Upgrade Node to 12 or later
affects: >=7.0.0
breakingtest-exclude update in v8.0.0 may change file exclusion behavior
fix
Review exclude/include patterns; test-exclude now uses glob matching based on minimatch
affects: >=8.0.0
deprecatedPlugin options passed directly to babel-plugin-istanbul are now preferred over package.json 'nyc' config
fix
Move exclude/include options to Babel plugin array: ["istanbul", { exclude: ["**/*.spec.js"] }]
affects: >=6.0.0
gotchaWhen using with ts-loader or other transpilers, ensure inline source maps are handled correctly. Setting useInlineSourceMaps to false can avoid memory issues.
fix
Set useInlineSourceMaps: false in plugin options if multiple build steps cause memory bloat.
affects: *
gotchaMust set nyc.sourceMap and nyc.instrument to false in package.json to avoid double instrumentation
fix
Add 'nyc': { 'sourceMap': false, 'instrument': false }
affects: *
Errors
Common errors & fixes
Error: container is falsy
Block scoping transform conflicts with instrumentation
fix
Update to babel-plugin-istanbul 7.0.0 or later, or ensure Babel config does not apply block scoping transform before instrumentation.
Error: Cannot find module 'babel-plugin-istanbul'
Plugin not installed or not in devDependencies
fix
Run: npm install --save-dev babel-plugin-istanbul
Error: Cannot find module 'test-exclude'
Missing dependency when using babel-plugin-istanbul v8 with npm <7 that doesn't auto-install peer dependencies
fix
Run: npm install --save-dev test-exclude
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
test-excluderequiredUsed to exclude files from instrumentation based on exclude/include patterns (breaking change in v8.0.0 updated to latest version)
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
babel-plugin-istanbul — npm install babel-plugin-istanbul · libregistry