Registry / testing / babel-preset-jest

babel-preset-jest

JSON →
library30.3.0jsnpmunverified

Babel preset for Jest, part of the Jest monorepo. Current version 30.3.0, released as part of Jest 30. This preset automatically configures Babel plugins needed for Jest to work with your code (e.g., transforms for ES modules, JSX, and TypeScript). Relies on @babel/core (peer dep) and babel-jest. Key differentiator: it's the official Jest preset, ensuring compatibility with Jest's internal module transformation. Actively maintained with frequent releases alongside Jest. Not to be used standalone; instead used via babel-jest or jest config.

npm install babel-preset-jest
INSTALL
IMPORT
SIG · BABEL-PRESET-JEST
B
babel-preset-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.

default
// No need to import directly; configure in Jest or Babel
import preset from 'babel-preset-jest'
Use via babel.config.js: module.exports = { presets: ['babel-preset-jest'] } or jest config transform
createTransformer
import { createTransformer } from 'babel-jest'
import { createTransformer } from 'babel-preset-jest'
createTransformer is in babel-jest, not babel-preset-jest
require presets
module.exports = { presets: ['jest'] }
const preset = require('babel-preset-jest'); module.exports = { presets: [preset] }
Simply use string 'jest' in Babel config; package resolution handles it

Shows how to configure Jest with babel-preset-jest in Babel config and how to let babel-jest apply it automatically.

// Install: npm install --save-dev babel-preset-jest @babel/core // In babel.config.js: module.exports = { presets: ['@babel/preset-env', 'jest'] }; // Or in jest.config.js: module.exports = { transform: { '^.+\\.jsx?$': 'babel-jest', }, // The preset is automatically applied when using babel-jest };
Debug
Known issues
breakingJest 30 dropped support for Node 16 and 18 (prior to 18.14), requiring Node >=18.14.
fix
Upgrade Node to >=18.14.0
affects: >=30.0.0
breakingJest 30 changed the default transform from babel-jest to a new runtime, but babel-preset-jest can still be used. If you rely on automatic Babel integration, you may need to explicitly configure `transform` in jest config.
fix
In jest.config.js: transform: { '^.+\\.jsx?$': 'babel-jest' }
affects: >=30.0.0
gotchababel-preset-jest is not imported directly; it's used via Babel config string 'jest' or automatically by babel-jest. Trying to import it as a module will not work.
fix
Use 'jest' as a string in presets array, or rely on babel-jest.
affects: *
deprecatedIn older Jest versions (<29), babel-preset-jest included @babel/plugin-transform-modules-commonjs by default. Starting from Jest 29, this plugin is no longer automatically added; you must install and configure it explicitly if needed.
fix
Install @babel/plugin-transform-modules-commonjs and add to your babel.config.js plugins array.
affects: <29.0.0
Errors
Common errors & fixes
Error: Requires Babel "^7.0.0-0", but was loaded with "8.0.0"
babel-preset-jest requires @babel/core version 7 or 8 beta, but you have version 8 stable installed.
fix
Install @babel/core@^7.11.0: npm install --save-dev @babel/core@^7.11.0
Module not found: Can't resolve 'babel-jest'
Missing babel-jest dependency when using jest's default babel transform.
fix
Install babel-jest: npm install --save-dev babel-jest
Jest: `babel-jest` is required for using the `.babelrc` or `babel.config.js` files. Install it: npm install --save-dev babel-jest
babel-jest is not installed but Jest is trying to use Babel transforms.
fix
Install babel-jest: npm install --save-dev babel-jest
Upgrade
Version history
30.3.0latest on npm
Audit
Dependencies
@babel/corerequiredpeer dependency: required by Babel to perform transformations
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
babel-preset-jest — npm install babel-preset-jest · libregistry