{"id":"586aaf13e5a295a1","repo":"jestjs/jest","slug":"the-selectprojects-option-requires-the-name-of-a","errorCode":null,"errorMessage":"The --selectProjects option requires the name of at least one project to be specified.\nExample usage: jest --selectProjects my-first-project my-second-project","messagePattern":"The --selectProjects option requires the name of at least one project to be specified\\.\nExample usage: jest --selectProjects my-first-project my-second-project","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-cli/src/args.ts","lineNumber":64,"sourceCode":"        'Example usage: jest --findRelatedTests ./src/source.js ' +\n        './src/index.js.',\n    );\n  }\n\n  if (\n    Object.prototype.hasOwnProperty.call(argv, 'maxWorkers') &&\n    argv.maxWorkers === undefined\n  ) {\n    throw new Error(\n      'The --maxWorkers (-w) option requires a number or string to be specified.\\n' +\n        'Example usage: jest --maxWorkers 2\\n' +\n        'Example usage: jest --maxWorkers 50%\\n' +\n        'Or did you mean --watch?',\n    );\n  }\n\n  if (argv.selectProjects && argv.selectProjects.length === 0) {\n    throw new Error(\n      'The --selectProjects option requires the name of at least one project to be specified.\\n' +\n        'Example usage: jest --selectProjects my-first-project my-second-project',\n    );\n  }\n\n  if (argv.ignoreProjects && argv.ignoreProjects.length === 0) {\n    throw new Error(\n      'The --ignoreProjects option requires the name of at least one project to be specified.\\n' +\n        'Example usage: jest --ignoreProjects my-first-project my-second-project',\n    );\n  }\n\n  if (\n    argv.config &&\n    !isJSONString(argv.config) &&\n    !new RegExp(\n      `\\\\.(${constants.JEST_CONFIG_EXT_ORDER.map(e => e.slice(1)).join('|')})$`,\n      'i',","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-cli/src/args.ts#L46-L82","documentation":"`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.","triggerScenarios":"`jest --selectProjects` with no project names following it; a script that expands `$PROJECTS` where the variable is empty.","commonSituations":"CI matrix scripts that conditionally set project names but run unconditionally; shell quoting that swallows the list.","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."],"exampleFix":"# before\njest --selectProjects\n\n# after\njest --selectProjects my-first-project my-second-project","handlingStrategy":"validation","validationCode":"function requireProjectNames(names?: string[]): string[] {\n  if (!names || names.length === 0) throw new Error('--selectProjects needs >=1 displayName');\n  return names;\n}","typeGuard":"const hasProjectNames = (a: any) => Array.isArray(a.selectProjects) && a.selectProjects.length > 0;","tryCatchPattern":null,"preventionTips":["Verify displayNames match the projects configured in jest.config.","Guard dynamic invocations when the name list may be empty."],"tags":["jest-cli","cli-args","projects","selectprojects"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}