jestjs/jest · critical · Error

jest: No configuration found for any project.

Error message

jest: No configuration found for any project.

What it means

readConfigs (index.ts:397-494) aggregates per-project configs and at the end requires a non-empty globalConfig and at least one project config (index.ts:486-488). If neither condition holds — no projects resolved, no config file was found anywhere — Jest has nothing to run and throws this terminal error.

Solutions

  1. Create a jest.config.js (or add a jest key to package.json) in the project root.
  2. Run jest from the directory containing the config, or pass --config <path> explicitly.
  3. Run jest --showConfig or jest --listTests to confirm Jest can discover configuration.
  4. If using projects, ensure at least one entry resolves to a directory with a config.

Example fix

// before: no jest config present
// after: create jest.config.js
module.exports = { testEnvironment: 'node' };
Defensive patterns

Strategy: validation

Validate before calling

import * as fs from 'node:fs';
import * as path from 'node:path';
const EXTS = ['.js','.ts','.mjs','.cjs','.json','.mts','.cts'];
function ensureJestConfigExists(root: string): void {
  const hasFile = EXTS.some(e => fs.existsSync(path.join(root, `jest.config${e}`)));
  const pkgJson = fs.existsSync(path.join(root, 'package.json')) ? require(path.join(root,'package.json')) : {};
  if (!hasFile && !pkgJson.jest) {
    throw new Error('No jest config found; create jest.config.js or add a jest key to package.json');
  }
}

Try / catch

try {
  const { globalConfig, configs } = await readConfigs(argv, projectPaths);
  // ...
} catch (e) {
  if ((e as Error).message.includes('No configuration found')) {
    console.error('No Jest config: run `npx jest --init` or add one.');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running jest in a directory with no jest.config.*, no jest key in package.json, and no parent directory containing one; pointing --config at a path that doesn't exist or resolves to nothing; a projects array whose entries were all filtered out (e.g. non-directory non-config files).

Common situations: Fresh project that hasn't created a config; wrong cwd (e.g. running from a subdirectory with no config and no upward resolution); deleted/moved config; CI checkout that excluded the config file; monorepo where every project dir was filtered out.

Related errors


AI-assisted analysis of jestjs/jest@8e6d128e4a (2026-08-10). Data as JSON: /api/errors/2d82d163e21618b1. Report an issue: GitHub.

Appendix: source

Thrown at packages/jest-config/src/index.ts:487

          );
        }),
    );

    ensureNoDuplicateConfigs(parsedConfigs, projects);
    configs = parsedConfigs.map(({projectConfig}) => projectConfig);
    if (!hasDeprecationWarnings) {
      hasDeprecationWarnings = parsedConfigs.some(
        ({hasDeprecationWarnings}) => !!hasDeprecationWarnings,
      );
    }
    // If no config was passed initially, use the one from the first project
    if (!globalConfig) {
      globalConfig = parsedConfigs[0].globalConfig;
    }
  }

  if (!globalConfig || configs.length === 0) {
    throw new Error('jest: No configuration found for any project.');
  }

  return {
    configs,
    globalConfig,
    hasDeprecationWarnings: !!hasDeprecationWarnings,
  };
}

View on GitHub (pinned to 8e6d128e4a)