webpack-babel-jest
raw JSON → 1.0.4 verified Sat Apr 25 auth: no javascript deprecated
A Jest preprocessor plugin that integrates Webpack and Babel for testing JavaScript files. Version 1.0.4 (latest) is deprecated in favor of modern Jest transform patterns. It works with old Jest configuration (scriptPreprocessor) and Babel-Jest, automatically ignoring CSS/SCSS/LESS imports. No active maintenance since 2016.
Common errors
error Could not find module 'webpack-babel-jest' from 'rootDir' ↓
cause Incorrect path or module not installed in project root.
fix
Install locally: npm install --save-dev webpack-babel-jest; check node_modules path.
error Cannot find module 'babel-jest' ↓
cause babel-jest is a required peer dependency not installed.
fix
Install babel-jest: npm install --save-dev babel-jest
Warnings
deprecated This package is unmaintained and relies on old Jest APIs. ↓
fix Use modern Jest transform: transform: { '^.+\\.js$': 'babel-jest' }
breaking Jest v20+ removed scriptPreprocessor; you must use transform instead. ↓
fix Remove scriptPreprocessor, use transform: { '^.+\\.js$': 'babel-jest' }
Install
npm install webpack-babel-jest yarn add webpack-babel-jest pnpm add webpack-babel-jest Imports
- default wrong
import webpackBabelJest from 'webpack-babel-jest';correctNot imported; configured via package.json jest.scriptPreprocessor - scriptPreprocessor wrong
scriptPreprocessor: require('webpack-babel-jest')correctjest.scriptPreprocessor = '<rootDir>/node_modules/webpack-babel-jest';
Quickstart
// package.json
{
"devDependencies": {
"webpack-babel-jest": "*",
"jest-cli": "*"
},
"scripts": {
"test": "jest"
},
"jest": {
"scriptPreprocessor": "<rootDir>/node_modules/webpack-babel-jest",
"testFileExtensions": ["es6", "js"],
"moduleFileExtensions": ["js", "json", "es6"]
}
}