{"id":20177,"library":"lab-babel","title":"lab-babel","description":"A transform for the lab test framework that enables testing of ES6/JSX modules transpiled with Babel, including code coverage and proper source maps. Current version: 1.1.1 (stable, low activity). This package integrates with lab's -T option to automatically transpile .js, .jsx, .es, and .es6 files (excluding node_modules) using Babel, preserving source maps for accurate error line numbers. Key differentiator: legacy dependency on babel-core (>=4.x.x); not intended for Babel 6+ without manual preset configuration (babel-preset-es2015). Not actively maintained; consider modern alternatives like @babel/register or ts-node.","status":"maintenance","version":"1.1.1","language":"javascript","source_language":"en","source_url":"git://github.com/nlf/lab-babel","tags":["javascript","lab","babel","coverage","test"],"install":[{"cmd":"npm install lab-babel","lang":"bash","label":"npm"},{"cmd":"yarn add lab-babel","lang":"bash","label":"yarn"},{"cmd":"pnpm add lab-babel","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Use the full path node_modules/lab-babel when specifying the -T option to lab. The package provides no JS exports; it's used as a CLI transform.","wrong":"npm install --save-dev lab-babel && lab -T lab-babel (relative path missing)","symbol":"lab-babel (transform)","correct":"lab -T node_modules/lab-babel"},{"note":"lab-babel depends on babel-core >=4.x.x, not @babel/core. Use CommonJS require.","wrong":"import babel from '@babel/core' (wrong package name for babel-core)","symbol":"babel-core","correct":"const babel = require('babel-core')"},{"note":"lab is a CommonJS module. The lab-babel transform does not change lab's API.","wrong":"import { script } from 'lab' (lab is CJS, not ESM)","symbol":"lab (test framework)","correct":"const Lab = require('lab'); const lab = exports.lab = Lab.script()"}],"quickstart":{"code":"npm install --save-dev lab babel-core babel-preset-es2015 lab-babel\necho '{\"presets\":[\"es2015\"]}' > .babelrc\n# test file: test/example.js\nconst Lab = require('lab');\nconst lab = exports.lab = Lab.script();\nconst Code = require('code');\nlab.test('transpiled ES6', (done) => {\n  const fn = (x) => x * 2;\n  Code.expect(fn(5)).to.equal(10);\n  done();\n});\n# run with: npx lab -T node_modules/lab-babel -t 100 -S","lang":"javascript","description":"Install lab-babel with babel-core and es2015 preset, configure .babelrc, write a trivial ES6 test using arrow functions, and run with lab's transform option."},"warnings":[{"fix":"Use @babel/register: npm install --save-dev @babel/core @babel/register @babel/preset-env; lab -T node_modules/@babel/register","message":"babel-core is deprecated in favor of @babel/core (Babel 7+). lab-babel only works with babel-core >=4.x.x and <7.x.x. For Babel 7+, use @babel/register or lab's built-in transform.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install babel-core: npm install --save-dev babel-core","message":"lab-babel requires babel-core as a peer dependency. If babel-core is not installed, lab will silently skip transpilation without error.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure your test files are in the project root directory (not in node_modules) and use one of the supported extensions.","message":"Only modules outside node_modules with extensions .js, .jsx, .es, .es6 are transpiled. Files in node_modules or with other extensions are ignored.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Create a .babelrc file with: { \"presets\": [\"es2015\"] } or install and configure babel-preset-env.","message":"Babel 6 requires explicit preset configuration (e.g., babel-preset-es2015). Without .babelrc or package.json babel section, transpilation fails silently.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev babel-core","cause":"Missing peer dependency babel-core required by lab-babel.","error":"Error: Cannot find module 'babel-core'"},{"fix":"npm install --save-dev babel-preset-es2015 and ensure .babelrc or package.json babel field includes 'presets': ['es2015']","cause":"Missing Babel preset when using Babel 6+.","error":"Error: Cannot find module 'babel-preset-es2015'"},{"fix":"Use: lab -T node_modules/lab-babel (full path). Ensure tests are .js, .jsx, .es, or .es6 files.","cause":"lab-babel not applied because -T flag missing or incorrect path.","error":"SyntaxError: Unexpected token import (or arrow functions) at runtime"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}