jestjs/jest · error · ValidationError
Configuration in ${packageJson} is not valid. Jest expects t
Error message
Configuration in ${packageJson} is not valid. Jest expects the string configuration to point to a file, but ${absolutePath} is not. Please check your Jest configuration in ${packageJson}. What it means
When the `jest` key in package.json is a string, Jest treats it as a path to a config file (a common shorthand). resolveConfigPathByTraversing resolves that string to an absolute path and checks it is a file; if not, it throws a ValidationError. This is distinct from the jest key being an inline object, which is always accepted.
Source
Thrown at packages/jest-config/src/resolveConfigPath.ts:89
skipMultipleConfigError: boolean,
): string => {
const configFiles = JEST_CONFIG_EXT_ORDER.map(ext =>
path.resolve(pathToResolve, getConfigFilename(ext)),
).filter(isFile);
const packageJson = findPackageJson(pathToResolve);
if (packageJson) {
const jestKey = getPackageJsonJestKey(packageJson);
if (jestKey) {
if (typeof jestKey === 'string') {
const absolutePath = path.isAbsolute(jestKey)
? jestKey
: path.resolve(pathToResolve, jestKey);
if (!isFile(absolutePath)) {
throw new ValidationError(
`${BULLET}Validation Error`,
` Configuration in ${chalk.bold(packageJson)} is not valid. ` +
`Jest expects the string configuration to point to a file, but ${absolutePath} is not. ` +
`Please check your Jest configuration in ${chalk.bold(
packageJson,
)}.`,
DOCUMENTATION_NOTE,
);
}
configFiles.push(absolutePath);
} else {
configFiles.push(packageJson);
}
}
}
if (!skipMultipleConfigError && configFiles.length > 1) {View on GitHub (pinned to f49721c78e)
Solutions
- Create the file the jest string points to, or correct the path
- Change the jest key to an inline object if you want config inside package.json
- Point the string at an existing absolute or correct relative path
Example fix
// before (package.json)
{ "jest": "./config/jest.js" }
// after
{ "jest": "./jest.config.js" } Defensive patterns
Strategy: validation
Validate before calling
import * as fs from 'node:fs';
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
if (typeof pkg.jest === 'string' && !fs.existsSync(pkg.jest)) {
throw new Error(`jest config file not found: ${pkg.jest}`);
} Prevention
- Keep the package.json jest string and the referenced file in sync
- Prefer an inline object for small configs to avoid path drift
When it happens
Trigger: Setting `"jest": "./jest.config.js"` in package.json when that file does not exist, or pointing it at a directory.
Common situations: Renaming or deleting the referenced config file without updating package.json; wrong relative path; pointing at a file outside the project root.
Related errors
- Multiple configurations found Implicit config resolution d
- For a percentage based memory limit a percentageReference mu
- Unexpected numerical input
- Unexpected input
- jest-haste-map: the `ignorePattern` option must be a RegExp
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/74d328959b9b8379.json.
Report an issue: GitHub.