eslint-import-resolver-jest
raw JSON → 3.0.2 verified Sat Apr 25 auth: no javascript
An ESLint resolver for eslint-plugin-import that resolves imports according to Jest's moduleNameMapper configuration. Version 3.0.2 is current stable (as of early 2025). Release cadence is irregular. It reads Jest config from package.json or a specified config file, enabling ESLint to understand aliased imports used in test files. Alternative to manual resolution override; integrates directly with eslint-plugin-import.
Common errors
error Unable to resolve path to module 'utils/helper'. ↓
cause Jest moduleNameMapper maps 'utils/helper' to '<rootDir>/src/utils/helper', but ESLint doesn't know about that mapping without this resolver.
fix
Install eslint-import-resolver-jest and configure in .eslintrc settings as shown in quickstart.
error Settings: Unknown resolver 'jest'. ↓
cause The resolver package is not installed or not listed in dependencies.
fix
Run: npm install eslint-import-resolver-jest --save-dev
Warnings
gotcha Resolved versions prior to 3.0.0 did not respect the Jest config file's '__esModule' option, leading to incorrect resolution. ↓
fix Upgrade to v3.0.0 or later.
gotcha If no jestConfigFile is specified, the resolver looks for a 'jest' key in package.json. It does NOT support jest.config.js or jest.config.ts by default. ↓
fix Explicitly set 'jestConfigFile' to your Jest config file path.
deprecated The resolver uses 'testRegex' and 'testMatch' from Jest config; if those are missing, it may resolve all files incorrectly. ↓
fix Ensure Jest config includes testRegex or testMatch.
breaking Version 2.x changed the default behavior to require explicit 'jestConfigFile' if not using package.json config. ↓
fix Update .eslintrc to include 'jestConfigFile' if you were relying on auto-detection from v1.
Install
npm install eslint-import-resolver-jest yarn add eslint-import-resolver-jest pnpm add eslint-import-resolver-jest Imports
- default resolver wrong
import resolver from 'eslint-import-resolver-jest'correct// In .eslintrc{"settings":{"import/resolver":{"jest":true}}} - JestResolverOptions wrong
const JestResolverOptions = require('eslint-import-resolver-jest')correctimport type { JestResolverOptions } from 'eslint-import-resolver-jest' - config via .eslintrc wrong
{"settings":{"import/resolver":{"jest":{"config":"./jest.config.js"}}}}correct{"settings":{"import/resolver":{"jest":{"jestConfigFile":"./jest.config.js"}}}}
Quickstart
// .eslintrc
{
"settings": {
"import/resolver": {
"jest": {
"jestConfigFile": "./jest.config.js"
}
}
}
}