babel-helper-plugin-test-runner

raw JSON →
6.24.1 verified Sat Apr 25 auth: no javascript

Internal Babel helper for running plugin tests. Version 6.24.1 is an older release from Babel 6 era. This package is part of Babel's monorepo and is not intended for direct external use. It provides a test runner helper for Babel plugins. The current stable major version is 7.x (e.g., 7.29.2) with Babel 8 (8.0.0-rc.3) in release candidate. Key differentiator: purely internal to Babel, not designed for public consumption, may have breaking changes across major versions. Use @babel/helper-plugin-test-runner for Babel 7+.

error Cannot find module 'babel-helper-plugin-test-runner'
cause Package not installed or mistake in package name (should be @babel/helper-plugin-test-runner for Babel 7+).
fix
npm install --save-dev @babel/helper-plugin-test-runner or install the older babel-helper-plugin-test-runner for Babel 6
error TypeError: pluginTester is not a function
cause Incorrect import; the default export is a function, but maybe using named import.
fix
Use import pluginTester from 'babel-helper-plugin-test-runner'
error babel-helper-plugin-test-runner is not compatible with @babel/core 7+
cause Using old package name with new Babel core.
fix
Switch to @babel/helper-plugin-test-runner
breaking Renamed from babel-helper-plugin-test-runner to @babel/helper-plugin-test-runner in Babel 7. Old package may not receive updates.
fix Update to @babel/helper-plugin-test-runner for Babel 7+
deprecated The package is internal to Babel and may break without notice across minor versions.
fix Consider using @babel/core's built-in test utilities or a dedicated test framework like Jest with babel-jest.
gotcha CommonJS require() works in v6 but is not the recommended import style; prefer ESM for consistency with modern Babel.
fix Use import statement or upgrade to Babel 7+ with @babel/helper-plugin-test-runner
gotcha The function exported may have changed signature between Babel 6 and 7; check documentation for your version.
fix Refer to version-specific docs on GitHub
npm install babel-helper-plugin-test-runner
yarn add babel-helper-plugin-test-runner
pnpm add babel-helper-plugin-test-runner

Example of using babel-helper-plugin-test-runner to test a Babel plugin with a code fixture.

import pluginTester from 'babel-helper-plugin-test-runner';
import myPlugin from './my-plugin';

const runTest = pluginTester(myPlugin);
const result = runTest({
  code: 'const x = 1;',
  snapshot: true
});
console.log(result);