Registry / testing / lab-babel

lab-babel

JSON →
library1.1.1jsnpmunverified

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.

npm install lab-babel
INSTALL
IMPORT
SIG · LAB-BABEL
L
lab-babel
testingjavascriptv1.1.1
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.

lab-babel (transform)
lab -T node_modules/lab-babel
npm install --save-dev lab-babel && lab -T lab-babel (relative path missing)
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.
babel-core
const babel = require('babel-core')
import babel from '@babel/core' (wrong package name for babel-core)
lab-babel depends on babel-core >=4.x.x, not @babel/core. Use CommonJS require.
lab (test framework)
const Lab = require('lab'); const lab = exports.lab = Lab.script()
import { script } from 'lab' (lab is CJS, not ESM)
lab is a CommonJS module. The lab-babel transform does not change lab's API.

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.

npm install --save-dev lab babel-core babel-preset-es2015 lab-babel echo '{"presets":["es2015"]}' > .babelrc # test file: test/example.js const Lab = require('lab'); const lab = exports.lab = Lab.script(); const Code = require('code'); lab.test('transpiled ES6', (done) => { const fn = (x) => x * 2; Code.expect(fn(5)).to.equal(10); done(); }); # run with: npx lab -T node_modules/lab-babel -t 100 -S
Debug
Known issues
deprecatedbabel-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.
fix
Use @babel/register: npm install --save-dev @babel/core @babel/register @babel/preset-env; lab -T node_modules/@babel/register
affects: >=1.0.0
gotchalab-babel requires babel-core as a peer dependency. If babel-core is not installed, lab will silently skip transpilation without error.
fix
Install babel-core: npm install --save-dev babel-core
affects: >=0.1.0
gotchaOnly modules outside node_modules with extensions .js, .jsx, .es, .es6 are transpiled. Files in node_modules or with other extensions are ignored.
fix
Ensure your test files are in the project root directory (not in node_modules) and use one of the supported extensions.
affects: >=0.1.0
deprecatedBabel 6 requires explicit preset configuration (e.g., babel-preset-es2015). Without .babelrc or package.json babel section, transpilation fails silently.
fix
Create a .babelrc file with: { "presets": ["es2015"] } or install and configure babel-preset-env.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-core'
Missing peer dependency babel-core required by lab-babel.
fix
npm install --save-dev babel-core
Error: Cannot find module 'babel-preset-es2015'
Missing Babel preset when using Babel 6+.
fix
npm install --save-dev babel-preset-es2015 and ensure .babelrc or package.json babel field includes 'presets': ['es2015']
SyntaxError: Unexpected token import (or arrow functions) at runtime
lab-babel not applied because -T flag missing or incorrect path.
fix
Use: lab -T node_modules/lab-babel (full path). Ensure tests are .js, .jsx, .es, or .es6 files.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
lab-babel — npm install lab-babel · libregistry