babel-helper-transform-fixture-test-runner
raw JSON → 6.26.2 verified Sat Apr 25 auth: no javascript maintenance
Internal Babel helper that provides a test runner for fixture-based tests within Babel's own monorepo. It is used in conjunction with babel-helper-fixtures to run transformation tests on a set of input/output fixtures. Current stable version is 6.26.2 (an older Babel 6 era package). Release cadence is tied to Babel releases. This package is not intended for direct use by consumers; it's an internal dependency for Babel development. Key differentiator: it is specific to Babel's test infrastructure and not a general-purpose testing utility.
Common errors
error Error: Cannot find module 'babel-helper-transform-fixture-test-runner' ↓
cause Package not installed or missing from node_modules. This package is an internal Babel dependency and not published to npm for general use.
fix
Install from npm: npm install babel-helper-transform-fixture-test-runner --save-dev, or switch to the scoped @babel/helper-transform-fixture-test-runner if using Babel 7+.
error TypeError: run is not a function ↓
cause Attempting to use the package without proper import or require. The exported value may be an object with a 'run' method.
fix
Use: const { run } = require('babel-helper-transform-fixture-test-runner');
Warnings
deprecated This package is part of Babel 6 and may not receive updates. Babel 7+ uses @babel/helper-transform-fixture-test-runner. ↓
fix Upgrade to the scoped @babel/helper-transform-fixture-test-runner package if using Babel 7+.
breaking In Babel 8, the package may be removed or renamed. Do not rely on this package for production code. ↓
fix Use Babel's official testing utilities like @babel/helper-plugin-test-runner instead.
gotcha The package expects fixtures in a specific directory structure. Incorrect fixture layout will cause silent failures or no tests run. ↓
fix Follow Babel's fixture convention: input.js and output.js in a test case folder. Refer to Babel's own test fixtures for examples.
Install
npm install babel-helper-transform-fixture-test-runner yarn add babel-helper-transform-fixture-test-runner pnpm add babel-helper-transform-fixture-test-runner Imports
- default wrong
const run = require('babel-helper-transform-fixture-test-runner')correctimport run from 'babel-helper-transform-fixture-test-runner' - run wrong
import run from 'babel-helper-transform-fixture-test-runner'correctconst run = require('babel-helper-transform-fixture-test-runner') - run wrong
const run = require('babel-helper-transform-fixture-test-runner').runcorrectconst { run } = require('babel-helper-transform-fixture-test-runner')
Quickstart
const run = require('babel-helper-transform-fixture-test-runner');
const path = require('path');
const testDir = path.join(__dirname, 'fixtures');
const opts = {
presets: ['@babel/preset-env'],
// Additional babel options
};
run(testDir, opts, function (err, results) {
if (err) {
console.error('Test failed:', err);
} else {
results.forEach(result => {
console.log(result.title, result.pass ? 'PASS' : 'FAIL');
});
}
});