jestjs/jest · error · Error
The --selectProjects option requires the name of at least on
Error message
The --selectProjects option requires the name of at least one project to be specified. Example usage: jest --selectProjects my-first-project my-second-project
What it means
`check` throws (packages/jest-cli/src/args.ts:63) when `--selectProjects` is supplied but the array is empty. selectProjects filters the `projects` config by `displayName`, so at least one name is required or the filter matches nothing.
Source
Thrown at packages/jest-cli/src/args.ts:64
'Example usage: jest --findRelatedTests ./src/source.js ' +
'./src/index.js.',
);
}
if (
Object.prototype.hasOwnProperty.call(argv, 'maxWorkers') &&
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',View on GitHub (pinned to f49721c78e)
Solutions
- Pass one or more project display names: `jest --selectProjects app-server web-client`.
- Guard the invocation when the name list is dynamic: `[ -n "$PROJECTS" ] && jest --selectProjects $PROJECTS`.
- Verify the names match `displayName` values in your jest.config projects array.
Example fix
# before jest --selectProjects # after jest --selectProjects my-first-project my-second-project
Defensive patterns
Strategy: validation
Validate before calling
function requireProjectNames(names?: string[]): string[] {
if (!names || names.length === 0) throw new Error('--selectProjects needs >=1 displayName');
return names;
} Type guard
const hasProjectNames = (a: any) => Array.isArray(a.selectProjects) && a.selectProjects.length > 0;
Prevention
- Verify displayNames match the projects configured in jest.config.
- Guard dynamic invocations when the name list may be empty.
When it happens
Trigger: `jest --selectProjects` with no project names following it; a script that expands `$PROJECTS` where the variable is empty.
Common situations: CI matrix scripts that conditionally set project names but run unconditionally; shell quoting that swallows the list.
Related errors
- The --ignoreProjects 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/586aaf13e5a295a1.json.
Report an issue: GitHub.