jestjs/jest · error · ValidationError
● Validation Error: Configuration in ${packageJson} is no
Error message
● Validation Error:
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
Thrown as a ValidationError when a package.json contains a 'jest' key whose value is a string (intended as a pointer to a config file) but that string does not resolve to an actual file. The string can be relative (resolved against the package.json's directory) or absolute; isFile must return true.
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 8e6d128e4a)
Solutions
- Create the file the string points to, or fix the path in package.json
- If you want inline config, change the 'jest' value to an object instead of a string
- Verify with ls that the resolved absolute path is a file
Example fix
// before: package.json
{
"jest": "./config/jest.base.js"
}
// (file does not exist)
// after: create the file, or fix the path
{
"jest": "./jest.config.js"
} Defensive patterns
Strategy: validation
Validate before calling
import * as fs from 'node:fs';
import * as path from 'node:path';
function assertPackageJsonJestKey(pkgPath: string): void {
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
if (typeof pkg.jest === 'string') {
const abs = path.isAbsolute(pkg.jest)
? pkg.jest
: path.resolve(path.dirname(pkgPath), pkg.jest);
if (!fs.existsSync(abs) || fs.lstatSync(abs).isDirectory()) {
throw new Error(`jest key in ${pkgPath} does not point to a file: ${abs}`);
}
}
} Type guard
function isFilePointer(value: unknown, baseDir: string): boolean {
if (typeof value !== 'string') return false;
const abs = path.isAbsolute(value) ? value : path.resolve(baseDir, value);
return fs.existsSync(abs) && !fs.lstatSync(abs).isDirectory();
} Prevention
- Prefer an inline object or a dedicated jest.config.* file over a string pointer
- When renaming config files, grep package.json for the old path
- In monorepos, use per-workspace configs rather than cross-package string pointers
When it happens
Trigger: Setting "jest": "./jest.config.js" in package.json when that file does not exist, or pointing to a directory rather than a file, or a typo in the relative path.
Common situations: Renaming/deleting the referenced config without updating package.json; monorepo where the relative path is correct in one package but copied to another with a different layout; pointing 'jest' at a folder.
Related errors
- Can't find a root directory while resolving a config file pa
- ● Multiple configurations found: * ${configPath} ..
- Could not find a config file based on provided values: path:
- The option summaryThreshold should be a number
- Could not find a "package.json" file in ${rootDir}
AI-assisted analysis of jestjs/jest@8e6d128e4a (2026-08-10).
Data as JSON: /api/errors/5ca7fdf17081a3e4.
Report an issue: GitHub.