{"id":20079,"library":"gulp-babel-istanbul","title":"gulp-babel-istanbul","description":"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.","status":"maintenance","version":"1.6.0","language":"javascript","source_language":"en","source_url":"git://github.com/cb1kenobi/gulp-babel-istanbul","tags":["javascript","gulpplugin","coverage","istanbul","unit test","babel"],"install":[{"cmd":"npm install gulp-babel-istanbul","lang":"bash","label":"npm"},{"cmd":"yarn add gulp-babel-istanbul","lang":"bash","label":"yarn"},{"cmd":"pnpm add gulp-babel-istanbul","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"gulp plugin","package":"gulp","optional":false},{"reason":"Babel transpilation dependency","package":"babel-core","optional":false},{"reason":"core coverage instrumenter","package":"istanbul","optional":false}],"imports":[{"note":"Default export is the istanbul function. CommonJS require is fine.","wrong":"const istanbul = require('gulp-babel-istanbul').default","symbol":"istanbul","correct":"import istanbul from 'gulp-babel-istanbul'"},{"note":"Available as named export from the same module.","wrong":"require('gulp-babel-istanbul').hookRequire","symbol":"hookRequire","correct":"import { hookRequire } from 'gulp-babel-istanbul'"},{"note":"writeReports is a named export, not a method on the default export.","wrong":"istanbul.writeReports()","symbol":"writeReports","correct":"import { writeReports } from 'gulp-babel-istanbul'"}],"quickstart":{"code":"const gulp = require('gulp');\nconst babel = require('gulp-babel');\nconst istanbul = require('gulp-babel-istanbul');\nconst mocha = require('gulp-mocha');\n\ngulp.task('coverage', function (cb) {\n  gulp.src('src/**/*.js')\n    .pipe(istanbul())\n    .pipe(istanbul.hookRequire())\n    .on('finish', function () {\n      gulp.src('test/**/*.js')\n        .pipe(babel())\n        .pipe(mocha())\n        .pipe(istanbul.writeReports())\n        .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }))\n        .on('end', cb);\n    });\n});","lang":"javascript","description":"Shows complete gulp task for instrumenting ES2015 source, running mocha tests, and generating coverage reports with threshold enforcement."},"warnings":[{"fix":"Call .pipe(istanbul.hookRequire()) before the finish event.","message":"hookRequire must be used in the same stream after istanbul()","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use Karma with karma-coverage instead for browser coverage.","message":"Browser testing is untested and may not work","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use gulp-babel with @babel/core and @babel/preset-env; this plugin uses babel-istanbul which may not be updated.","message":"babel-core is replaced by @babel/core","severity":"deprecated","affected_versions":">=1.6.0"},{"fix":"Use CommonJS modules or transpile to CJS before testing.","message":"require hook does not work with ESM modules","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install babel-core@^6 --save-dev","cause":"Plugin expects babel-istanbul but babel-core is not installed or outdated","error":"Error: Cannot find module 'babel/register'"},{"fix":"Use require('gulp-babel-istanbul').hookRequire or import { hookRequire } from 'gulp-babel-istanbul'","cause":"hookRequire is not called on the default export directly","error":"TypeError: istanbul.hookRequire is not a function"},{"fix":"Ensure istanbul() and hookRequire() are applied before running tests","cause":"writeReports expects a coverage variable that may not exist","error":"ENOENT: no such file or directory, open 'coverage/lcov.info'"},{"fix":"Set { includeUntested: true } and ensure hookRequire() is piped","cause":"includeUntested option false by default and require hook not applied","error":"The coverage report is empty"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}