{"record":{"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":"exception","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/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-cli/src/args.ts#L46-L82","documentation":"check() requires that --selectProjects, which takes one or more project display names (args.ts:55-65 in options, validation at 63-68), be given at least one name. With an empty array there is no project to run, so Jest fails fast rather than silently running nothing.","triggerScenarios":"Running jest --selectProjects with no names; passing --selectProjects= (empty); a script that interpolates a project-name variable that resolved to empty.","commonSituations":"Automated matrix where the project list is computed and happens to be empty; copy-paste from docs omitting the example args; CI config that conditionally selects projects but the condition yields nothing.","solutions":["Pass at least one project displayName: jest --selectProjects my-first-project my-second-project.","Ensure each named project has displayName set in its config (otherwise selection silently matches nothing later).","If the list is dynamic, skip the flag entirely when the list is empty rather than passing an empty value."],"exampleFix":"// before\njest --selectProjects\n// after\njest --selectProjects my-first-project my-second-project","handlingStrategy":"validation","validationCode":"function selectProjectsArg(names: string[]): string[] {\n  if (names.length === 0) throw new Error('--selectProjects needs >= 1 name');\n  return ['--selectProjects', ...names];\n}","typeGuard":"function isNonEmptyStringArray(v: unknown): v is string[] {\n  return Array.isArray(v) && v.length > 0 && v.every(x => typeof x === 'string');\n}","tryCatchPattern":null,"preventionTips":["Ensure every project has a displayName in its config so selection matches.","Skip the flag entirely when the computed project list is empty.","Cross-check names against the config's displayName values."],"tags":["jest-cli","cli-args","selectprojects","multi-project","missing-argument"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}