{"record":{"id":"48155784e9d35da1","repo":"jestjs/jest","slug":"both-onlyfailures-and-watchall-were-specified","errorCode":null,"errorMessage":"Both --onlyFailures and --watchAll were specified, only one is allowed.","messagePattern":"Both --onlyFailures and --watchAll were specified, only one is allowed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-cli/src/args.ts","lineNumber":38,"sourceCode":"  }\n\n  for (const key of [\n    'onlyChanged',\n    'lastCommit',\n    'changedFilesWithAncestor',\n    'changedSince',\n  ]) {\n    if (argv[key] && argv.watchAll) {\n      throw new Error(\n        `Both --${key} and --watchAll were specified, but cannot be used ` +\n          'together. Try the --watch option which reruns only tests ' +\n          'related to changed files.',\n      );\n    }\n  }\n\n  if (argv.onlyFailures && argv.watchAll) {\n    throw new Error(\n      'Both --onlyFailures and --watchAll were specified, only one is allowed.',\n    );\n  }\n\n  if (argv.findRelatedTests && argv._.length === 0) {\n    throw new Error(\n      'The --findRelatedTests option requires file paths to be specified.\\n' +\n        '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' +","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-cli/src/args.ts#L20-L56","documentation":"check() separately rejects --onlyFailures together with --watchAll (args.ts:37-41) because --onlyFailures relies on a static snapshot of the previous run's results, while --watchAll continuously reruns everything. The two modes operate on incompatible notions of which tests to select.","triggerScenarios":"Running jest --onlyFailures --watchAll; jest -f --watchAll; combining a flaky-test rerun workflow with watch-all development.","commonSituations":"Adding --watchAll to a script that already uses --onlyFailures to chase down failing tests; aliasing watch to watchAll by mistake.","solutions":["Drop --watchAll if you want to keep rerunning only previously-failed tests.","Switch to plain --watch (reruns tests related to changed files) instead of --watchAll if you want live feedback.","If you want both behaviors, run them as separate jest invocations."],"exampleFix":"// before\njest --onlyFailures --watchAll\n// after\njest --onlyFailures","handlingStrategy":"validation","validationCode":"function validateFlags(argv: { onlyFailures?: boolean; watchAll?: boolean }): void {\n  if (argv.onlyFailures && argv.watchAll) {\n    throw new Error('--onlyFailures and --watchAll are mutually exclusive');\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep --onlyFailures for one-shot reruns; use --watch (not --watchAll) for live feedback.","Build a small CLI-flag wrapper that rejects known-incompatible pairs."],"tags":["jest-cli","cli-args","conflicting-flags","watch","onlyfailures"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}