{"record":{"id":"5ca7fdf17081a3e4","repo":"jestjs/jest","slug":"validation-error-configuration-in-packagej","errorCode":null,"errorMessage":"● Validation Error:\n\n  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}.","messagePattern":"● Validation Error:\n\n  Configuration in (.+?) is not valid\\. Jest expects the string configuration to point to a file, but (.+?) is not\\. Please check your Jest configuration in (.+?)\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/jest-config/src/resolveConfigPath.ts","lineNumber":89,"sourceCode":"  skipMultipleConfigError: boolean,\n): string => {\n  const configFiles = JEST_CONFIG_EXT_ORDER.map(ext =>\n    path.resolve(pathToResolve, getConfigFilename(ext)),\n  ).filter(isFile);\n\n  const packageJson = findPackageJson(pathToResolve);\n\n  if (packageJson) {\n    const jestKey = getPackageJsonJestKey(packageJson);\n\n    if (jestKey) {\n      if (typeof jestKey === 'string') {\n        const absolutePath = path.isAbsolute(jestKey)\n          ? jestKey\n          : path.resolve(pathToResolve, jestKey);\n\n        if (!isFile(absolutePath)) {\n          throw new ValidationError(\n            `${BULLET}Validation Error`,\n            `  Configuration in ${chalk.bold(packageJson)} is not valid. ` +\n              `Jest expects the string configuration to point to a file, but ${absolutePath} is not. ` +\n              `Please check your Jest configuration in ${chalk.bold(\n                packageJson,\n              )}.`,\n            DOCUMENTATION_NOTE,\n          );\n        }\n\n        configFiles.push(absolutePath);\n      } else {\n        configFiles.push(packageJson);\n      }\n    }\n  }\n\n  if (!skipMultipleConfigError && configFiles.length > 1) {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-config/src/resolveConfigPath.ts#L71-L107","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: package.json\n{\n  \"jest\": \"./config/jest.base.js\"\n}\n// (file does not exist)\n\n// after: create the file, or fix the path\n{\n  \"jest\": \"./jest.config.js\"\n}","handlingStrategy":"validation","validationCode":"import * as fs from 'node:fs';\nimport * as path from 'node:path';\nfunction assertPackageJsonJestKey(pkgPath: string): void {\n  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));\n  if (typeof pkg.jest === 'string') {\n    const abs = path.isAbsolute(pkg.jest)\n      ? pkg.jest\n      : path.resolve(path.dirname(pkgPath), pkg.jest);\n    if (!fs.existsSync(abs) || fs.lstatSync(abs).isDirectory()) {\n      throw new Error(`jest key in ${pkgPath} does not point to a file: ${abs}`);\n    }\n  }\n}","typeGuard":"function isFilePointer(value: unknown, baseDir: string): boolean {\n  if (typeof value !== 'string') return false;\n  const abs = path.isAbsolute(value) ? value : path.resolve(baseDir, value);\n  return fs.existsSync(abs) && !fs.lstatSync(abs).isDirectory();\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["config","package-json","filesystem","validation"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}