Registry / testing / babel-jest

babel-jest

JSON →
library30.3.0jsnpmunverified

Jest plugin to use Babel for transformation of source files during testing. Current stable version is 30.3.0 (released 2025). It is part of the Jest monorepo and follows Jest's release cadence. Key differentiators: integrates tightly with Jest's transform pipeline, automatically picks up Babel configuration, supports custom transformers and presets, and is ESM-compatible. It is the recommended way to transpile modern JavaScript and TypeScript code in Jest tests when using Babel. Compared to alternative transformers like ts-jest, babel-jest is faster but does not perform type checking.

npm install babel-jest
INSTALL
IMPORT
SIG · BABEL-JEST
B
babel-jest
testingjavascriptv30.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createTransformer
import { createTransformer } from 'babel-jest'
const { createTransformer } = require('babel-jest')
ESM-only since Jest 28; require() will fail in recent versions.
default (default export)
import babelJest from 'babel-jest'
const babelJest = require('babel-jest').default
Default export is the transformer object used in Jest config. Using require().default works in CJS but is not recommended.
TransformerConfig
import type { TransformerConfig } from 'babel-jest'
import { TransformerConfig } from 'babel-jest'
TransformerConfig is a type export only available from Jest 30.2.0. Use type import to avoid runtime error.

Configures babel-jest as the transformer for .js/.ts files in Jest, using createTransformer with custom Babel presets.

// jest.config.js import babelJest from 'babel-jest'; export default { transform: { '^.+\\.jsx?$': babelJest, '^.+\\.tsx?$': [ babelJest.createTransformer({ presets: [ ['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript', ], }), ], }, }; // Alternatively, use the createTransformer function with custom options. // This shows how to set up babel-jest for both JS and TS files.
Debug
Known issues
breakingbabel-jest is now ESM-only starting from Jest 28. Using require() will throw an error.
fix
Use import statements instead of require(). If you must use CommonJS, use dynamic import or upgrade your project to ESM.
affects: >=28
breakingIn Jest 30, the 'createTransformer' function returns a different object type. Some custom transform options may not work as before.
fix
Review the changelog for Jest 30 and update custom transformers accordingly.
affects: >=30
deprecatedThe default export (babelJest) is still supported but using createTransformer is preferred for explicit configuration.
fix
Replace usage of default export with createTransformer for clarity and future-proofing.
affects: >=28
gotchababel-jest does not perform type checking. It only strips types when using TypeScript. For type checking, use ts-jest or run tsc separately.
fix
Add a separate type check step in your CI or use the TypeScript compiler as a separate test.
affects: all
Errors
Common errors & fixes
Error: Jest: 'babel-jest' is not a valid transformer. Must be a function or an object with a 'process' method.
Using require() to import babel-jest in ESM-only mode, or misconfiguration in Jest transform.
fix
Ensure you are using import statements and that the transform is correctly set (e.g., use 'import babelJest from "babel-jest"').
Cannot find module '@babel/core' from 'babel-jest'
Missing required peer dependency @babel/core.
fix
Run 'npm install --save-dev @babel/core' or 'yarn add --dev @babel/core'.
TypeError: babelJest.createTransformer is not a function
Using an older version of babel-jest (pre-28) where createTransformer did not exist, or incorrect import.
fix
Upgrade to babel-jest v28+ and use 'import { createTransformer } from "babel-jest"'.
SyntaxError: Cannot use import statement outside a module
Using ESM syntax in a CommonJS file without proper .mjs extension or 'type' module in package.json.
fix
Add 'type': 'module' to package.json, or rename file to .mjs, or use require syntax for CJS.
Upgrade
Version history
30.3.0latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency required for Babel transformation.
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
babel-jest — npm install babel-jest · libregistry