Registry / testing / gulp-babel-istanbul

gulp-babel-istanbul

JSON →
library1.6.0jsnpmunverified

A gulp plugin that instruments source files with Istanbul code coverage after Babel transpilation, enabling ES2015+ coverage reporting. Version 1.6.0 (latest) uses babel-istanbul under the hood. It integrates with any Node.js test framework via gulp, providing hooks for require and reports. Compared to alternatives like gulp-istanbul, it natively handles Babel-transpiled code. Browser testing is untested. Requires gulp, babel, and Istanbul. Slow release cadence; last update 2016. Consider seamless builds with webpack or karma for browser coverage.

npm install gulp-babel-istanbul
INSTALL
IMPORT
SIG · GULP-BABEL-ISTANBU
G
gulp-babel-istanbul
testingjavascriptv1.6.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.

istanbul
import istanbul from 'gulp-babel-istanbul'
const istanbul = require('gulp-babel-istanbul').default
Default export is the istanbul function. CommonJS require is fine.
hookRequire
import { hookRequire } from 'gulp-babel-istanbul'
require('gulp-babel-istanbul').hookRequire
Available as named export from the same module.
writeReports
import { writeReports } from 'gulp-babel-istanbul'
istanbul.writeReports()
writeReports is a named export, not a method on the default export.

Shows complete gulp task for instrumenting ES2015 source, running mocha tests, and generating coverage reports with threshold enforcement.

const gulp = require('gulp'); const babel = require('gulp-babel'); const istanbul = require('gulp-babel-istanbul'); const mocha = require('gulp-mocha'); gulp.task('coverage', function (cb) { gulp.src('src/**/*.js') .pipe(istanbul()) .pipe(istanbul.hookRequire()) .on('finish', function () { gulp.src('test/**/*.js') .pipe(babel()) .pipe(mocha()) .pipe(istanbul.writeReports()) .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) .on('end', cb); }); });
Debug
Known issues
gotchahookRequire must be used in the same stream after istanbul()
fix
Call .pipe(istanbul.hookRequire()) before the finish event.
affects: >=1.0.0
gotchaBrowser testing is untested and may not work
fix
Use Karma with karma-coverage instead for browser coverage.
affects: >=1.0.0
deprecatedbabel-core is replaced by @babel/core
fix
Use gulp-babel with @babel/core and @babel/preset-env; this plugin uses babel-istanbul which may not be updated.
affects: >=1.6.0
gotcharequire hook does not work with ESM modules
fix
Use CommonJS modules or transpile to CJS before testing.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel/register'
Plugin expects babel-istanbul but babel-core is not installed or outdated
fix
npm install babel-core@^6 --save-dev
TypeError: istanbul.hookRequire is not a function
hookRequire is not called on the default export directly
fix
Use require('gulp-babel-istanbul').hookRequire or import { hookRequire } from 'gulp-babel-istanbul'
ENOENT: no such file or directory, open 'coverage/lcov.info'
writeReports expects a coverage variable that may not exist
fix
Ensure istanbul() and hookRequire() are applied before running tests
The coverage report is empty
includeUntested option false by default and require hook not applied
fix
Set { includeUntested: true } and ensure hookRequire() is piped
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies
gulprequiredgulp plugin
babel-corerequiredBabel transpilation dependency
istanbulrequiredcore coverage instrumenter
Agent activity
6 hits · last 30 days
node
6
Resources
gulp-babel-istanbul — npm install gulp-babel-istanbul · libregistry