{"id":19175,"library":"babel-plugin-tester","title":"babel-plugin-tester","description":"Utilities for writing tests for Babel plugins and presets. Version 12.0.0 is current. The library supports Jest, Mocha, Jasmine, node:test, and Vitest. Key differentiators: automatic fixture file loading, built-in prettier formatting, snapshot-based testing, environment variable filtering (TEST_ONLY, TEST_SKIP), and async ResultFormatter. Breaking changes in v12 include dropping default exports, requiring Node.js >=20.18.0, and adopting prettier@3's async interface. Peer dependency on @babel/core >=7.22.0.","status":"active","version":"12.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/babel-utils/babel-plugin-tester","tags":["javascript","babel","plugin","tester"],"install":[{"cmd":"npm install babel-plugin-tester","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-tester","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-tester","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for transforming code with Babel plugins/presets.","package":"@babel/core","optional":false}],"imports":[{"note":"Default export was removed in v12. Use named import only.","wrong":"import pluginTester from 'babel-plugin-tester'","symbol":"pluginTester","correct":"import { pluginTester } from 'babel-plugin-tester'"},{"note":"Available as a named export; commonly used to format output with Prettier.","symbol":"prettierFormatter","correct":"import { prettierFormatter } from 'babel-plugin-tester'"},{"note":"CJS require must destructure the named export. Default require returns an object with named exports.","wrong":"const pluginTester = require('babel-plugin-tester')","symbol":"pluginTester (CJS)","correct":"const { pluginTester } = require('babel-plugin-tester')"}],"quickstart":{"code":"import { pluginTester } from 'babel-plugin-tester';\nimport myPlugin from './my-plugin';\n\npluginTester({\n  plugin: myPlugin,\n  tests: {\n    'transforms correctly': {\n      code: 'const x = 1;',\n      output: 'const x = 1;',\n    },\n    'snapshot test': {\n      code: 'const y = 2;',\n      snapshot: true,\n    },\n  },\n});","lang":"typescript","description":"Basic test suite for a Babel plugin with inline code tests and a snapshot test."},"warnings":[{"fix":"Change `import pluginTester from 'babel-plugin-tester'` to `import { pluginTester } from 'babel-plugin-tester'`.","message":"Default export removed in v12. Import { pluginTester } instead of default import.","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"Upgrade Node.js to >=20.18.0.","message":"Minimum Node.js version is now 20.18.0 (v12).","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"If using custom formatter, ensure it returns a Promise or use async/await.","message":"ResultFormatter is now async (returns Promise) due to prettier@3.","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"Run tests with `NODE_OPTIONS='--no-warnings --experimental-vm-modules' npx jest`.","message":"With prettier@3, some Node versions require --experimental-vm-modules flag.","severity":"gotcha","affected_versions":">=12.0.0"},{"fix":"Move shared options to the top-level pluginTester configuration.","message":"Implicit global option merging removed in v11. All options must be explicitly set per test or via global config.","severity":"breaking","affected_versions":">=11.0.0 <12.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change to named import: `import { pluginTester } from 'babel-plugin-tester'`","cause":"Using default import with v12+ which removed default export.","error":"TypeError: pluginTester is not a function"},{"fix":"Run `npm install --save-dev babel-plugin-tester` and ensure import path is correct.","cause":"Missing install or wrong import path.","error":"Error: Cannot find module 'babel-plugin-tester'"},{"fix":"Check plugin logic and verify test input/output.","cause":"Test output mismatch; plugin may not be transforming as expected.","error":"AssertionError: expected 'const x = 1;' to equal 'const x = 2;'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}