Jest Runner ESLint
raw JSON → 2.3.0 verified Sat Apr 25 auth: no javascript
An ESLint runner for Jest v2.3.0 that integrates ESLint linting as a Jest test runner. It supports ESLint 7/8 and Jest 27-30, with flat config support since v2.1.0. Released under the jest-community organization, it is actively maintained with a release cadence of several times per year. Key differentiators include watch mode with fix toggling via a watch plugin, multi-project support, and cosmiconfig configuration.
Common errors
error Could not locate jest-runner-eslint config file ↓
cause Missing cosmiconfig configuration file
fix
Create jest-runner-eslint.config.js or add jest-runner-eslint key in package.json
error Jest: Test match is not scoped correctly ↓
cause testMatch includes test files or includes all files
fix
Set testMatch to only include source files you want linted, e.g., '<rootDir>/src/**/*.js'
error ESLint: Failed to load config 'eslint:recommended' ↓
cause ESLint config not found or incompatible
fix
Ensure ESLint is installed and config file is correct; for flat config, use v2.1.0+
error Cannot find module 'jest-runner-eslint' ↓
cause Package not installed or not in correct node_modules
fix
Run npm install --save-dev jest-runner-eslint
Warnings
breaking Dropped support for Node 10, ESLint 6, Jest 25/26 in v2.0.0 ↓
fix Upgrade Node to >=12.13.0, ESLint to >=7, Jest to >=27
breaking Flat config support requires ESLint >=8.57.0 or ESLint 9 with flat config ↓
fix Use eslint.config.js and ensure ESLint version is compatible
deprecated Jest 27-30 supported; older Jest versions are not supported ↓
fix Upgrade Jest to version 27 or later
gotcha Use projects configuration to run alongside other Jest runners; otherwise testMatch must be scoped ↓
fix Use projects array in Jest config, or set testMatch to only lint files
gotcha cliOptions.fix was ignored until v2.1.1 ↓
fix Upgrade to v2.1.1 or later
gotcha Quiet mode may not suppress warnings correctly before v2.1.2 ↓
fix Upgrade to v2.1.2 or later
Install
npm install jest-runner-eslint yarn add jest-runner-eslint pnpm add jest-runner-eslint Imports
- jest-runner-eslint wrong
const JestRunnerEslint = require('jest-runner-eslint'); // Not a direct importcorrect// In Jest config: runner: 'jest-runner-eslint' - jest-runner-eslint/watch-fix
watchPlugins: ['jest-runner-eslint/watch-fix'] - default (cosmiconfig) wrong
require('jest-runner-eslint').config(...) // No such exportcorrect// In jest-runner-eslint.config.js: module.exports = { cliOptions: { fix: true } }
Quickstart
// jest-eslint.config.js
module.exports = {
runner: 'jest-runner-eslint',
displayName: 'lint',
testMatch: ['<rootDir>/src/**/*.js'],
// Optional: add watch plugin
watchPlugins: ['jest-runner-eslint/watch-fix'],
};
// jest.config.js (or package.json)
module.exports = {
projects: [
{ displayName: 'test' },
'<rootDir>/jest-eslint.config.js',
],
};