An opinionated library for testing Babel plugins with Jest or Mocha, using fixture files instead of snapshots. Current stable version is 0.2.4 (last released October 2020, low release cadence). Integrates with Jest's snapshot feature to auto-update fixture outputs on keypress, avoiding manual copy-paste. Simpler API than alternatives like @babel/helper-plugin-test-runner or babel-plugin-tester; focuses on directory-based fixtures with code.js/output.js/error.js pattern. Ships TypeScript types.
npm install babel-testVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating a test helper with babel-test using a fixture directory and lifecycle hooks.
If you need external config, pass babelrc: true or configFile: true explicitly in the config object.
Use 'fixtures' instead for directory-based tests. For single-file tests, consider using 'babel-plugin-tester'.
Name directories exactly as 'skip.my-test' or 'only.my-test' (all lowercase before dot).
Version control fixture files. Use --ci mode to prevent accidental updates.
Run npm install --save-dev @babel/core (or babel-core for v6).
Ensure each fixture subdirectory contains a code.js file. See documentation for required structure.
Change import create from 'babel-test' to import { create } from 'babel-test'.