{"id":19368,"library":"babel-test","title":"babel-test","description":"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.","status":"active","version":"0.2.4","language":"javascript","source_language":"en","source_url":"https://github.com/satya164/babel-test","tags":["javascript","babel","jest","test","typescript"],"install":[{"cmd":"npm install babel-test","lang":"bash","label":"npm"},{"cmd":"yarn add babel-test","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-test","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to transform code during tests","package":"babel-core","optional":false}],"imports":[{"note":"Package ships TypeScript types and supports both ESM and CJS. Named import required.","wrong":"const create = require('babel-test')","symbol":"create","correct":"import { create } from 'babel-test'"},{"note":"This package does not have a default export; only named export 'create'.","wrong":"import create from 'babel-test'","symbol":"default import","correct":"import { create } from 'babel-test'"},{"note":"The 'test' function is returned from the create() call, not exported directly.","wrong":"const { test } = require('babel-test')","symbol":"test","correct":"const { test } = create({ plugins: [...] })"}],"quickstart":{"code":"import path from 'path';\nimport { create } from 'babel-test';\n\nconst { fixtures } = create({\n  plugins: [['path/to/plugin', { option1: true }]],\n});\n\nfixtures('my plugin tests', path.join(__dirname, '__fixtures__'), {\n  beforeEach() {\n    console.log('Running setup...');\n  },\n});\n// Directory structure:\n// __fixtures__/\n//   simple-transform/\n//     code.js\n//     output.js\n//   error-case/\n//     code.js\n//     error.js","lang":"typescript","description":"Demonstrates creating a test helper with babel-test using a fixture directory and lifecycle hooks."},"warnings":[{"fix":"If you need external config, pass babelrc: true or configFile: true explicitly in the config object.","message":"The 'create' function sets babelrc and configFile to false by default to avoid external config interference.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use 'fixtures' instead for directory-based tests. For single-file tests, consider using 'babel-plugin-tester'.","message":"The 'test' function returned from create() is undocumented and may be removed in future versions.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Name directories exactly as 'skip.my-test' or 'only.my-test' (all lowercase before dot).","message":"Fixture directories prefixed with 'skip.' or 'only.' are case-sensitive and must be lowercase.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Version control fixture files. Use --ci mode to prevent accidental updates.","message":"If using Jest's --updateSnapshot flag, fixture output files are overwritten automatically; this may cause data loss if output.js is hand-edited.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev @babel/core (or babel-core for v6).","cause":"babel-core is a peer dependency and not installed automatically.","error":"Cannot find module 'babel-core'"},{"fix":"Ensure each fixture subdirectory contains a code.js file. See documentation for required structure.","cause":"Fixture directory structure is incorrect; missing code.js file.","error":"ENOENT: no such file or directory, open '.../__fixtures__/test/code.js'"},{"fix":"Change import create from 'babel-test' to import { create } from 'babel-test'.","cause":"Default import used instead of named import.","error":"TypeError: (0 , _babelTest.create) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}