babel-7-jest
raw JSON → 21.3.3 verified Sat Apr 25 auth: no javascript deprecated
Deprecated Jest transform plugin bridging babel-jest with @babel/core v7 before official support existed. Latest version 21.3.3, originally required @babel/core ^7.0.0-alpha/beta. Now superseded by babel-jest with babel-core@7.0.0-bridge.0. Do not use for new projects; official solution is stable and actively maintained.
Common errors
error Cannot find module '@babel/core' ↓
cause @babel/core not installed or peer dep not satisfied
fix
npm install --save-dev @babel/core@^7.0.0
error babel-7-jest is deprecated. Use babel-jest instead. ↓
cause Using deprecated package; npm warns on install
fix
Remove babel-7-jest and configure babel-jest as per official docs
Warnings
deprecated Package is deprecated; use official babel-jest with babel-core@7.0.0-bridge.0 instead. ↓
fix npm uninstall babel-7-jest && npm install --save-dev babel-jest @babel/core babel-core@7.0.0-bridge.0
breaking Requires exact @babel/core version matching peer dep (^7.0.0-alpha/beta). ↓
fix Use @babel/core ^7.0.0
gotcha Not compatible with Jest versions beyond 21.x due to API changes. ↓
fix Upgrade to official babel-jest for Jest 22+
Install
npm install babel-7-jest yarn add babel-7-jest pnpm add babel-7-jest Imports
- babel-7-jest wrong
import babel7Jest from 'babel-7-jest'correct"babel-7-jest" (string in jest config)
Quickstart
// package.json snippet (not runnable alone)
{
"scripts": {
"test": "jest"
},
"jest": {
"transform": {
".js$": "babel-7-jest"
}
},
"devDependencies": {
"@babel/core": "^7.0.0",
"babel-7-jest": "^21.3.3",
"jest": "^21.0.0"
}
}
// No JS code needed; config-based transform.