jestjs/jest · error · Error
The --ignoreProjects option requires the name of at least on
Error message
The --ignoreProjects option requires the name of at least one project to be specified. Example usage: jest --ignoreProjects my-first-project my-second-project
What it means
Mirror of the selectProjects guard: `check` throws (packages/jest-cli/src/args.ts:70) when `--ignoreProjects` is given an empty array. ignoreProjects excludes projects by `displayName`, so at least one name must be supplied.
Source
Thrown at packages/jest-cli/src/args.ts:71
argv.maxWorkers === undefined
) {
throw new Error(
'The --maxWorkers (-w) option requires a number or string to be specified.\n' +
'Example usage: jest --maxWorkers 2\n' +
'Example usage: jest --maxWorkers 50%\n' +
'Or did you mean --watch?',
);
}
if (argv.selectProjects && argv.selectProjects.length === 0) {
throw new Error(
'The --selectProjects option requires the name of at least one project to be specified.\n' +
'Example usage: jest --selectProjects my-first-project my-second-project',
);
}
if (argv.ignoreProjects && argv.ignoreProjects.length === 0) {
throw new Error(
'The --ignoreProjects option requires the name of at least one project to be specified.\n' +
'Example usage: jest --ignoreProjects my-first-project my-second-project',
);
}
if (
argv.config &&
!isJSONString(argv.config) &&
!new RegExp(
`\\.(${constants.JEST_CONFIG_EXT_ORDER.map(e => e.slice(1)).join('|')})$`,
'i',
).test(argv.config)
) {
throw new Error(
`The --config option requires a JSON string literal, or a file path with one of these extensions: ${constants.JEST_CONFIG_EXT_ORDER.join(
', ',
)}.\nExample usage: jest --config ./jest.config.js`,
);View on GitHub (pinned to f49721c78e)
Solutions
- Pass the project display names to ignore: `jest --ignoreProjects e2e-heavy`.
- Guard the call site when the list is dynamic: only add the flag when names exist.
- Confirm each name matches a configured `displayName`.
Example fix
# before jest --ignoreProjects # after jest --ignoreProjects slow-e2e integration
Defensive patterns
Strategy: validation
Validate before calling
function requireIgnoreNames(names?: string[]): string[] {
if (!names || names.length === 0) throw new Error('--ignoreProjects needs >=1 displayName');
return names;
} Type guard
const hasIgnoreNames = (a: any) => Array.isArray(a.ignoreProjects) && a.ignoreProjects.length > 0;
Prevention
- Confirm each ignored name is a real displayName.
- Only add the flag when the name list is non-empty.
When it happens
Trigger: `jest --ignoreProjects` with no names; dynamic name list that resolved to empty.
Common situations: Scripts that build an ignore list from a conditionally-empty variable; CI configs left with a placeholder.
Related errors
- The --selectProjects option requires the name of at least on
- Both --runInBand and --maxWorkers were specified, only one i
- Both --${key} and --watchAll were specified, but cannot be u
- Both --onlyFailures and --watchAll were specified, only one
- The --findRelatedTests option requires file paths to be spec
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/48db43f87bcea5f1.json.
Report an issue: GitHub.