jestjs/jest · error · ValidationError
${deprecationEntries[name](argv)}
Error message
${deprecationEntries[name](argv)} What it means
Thrown by `validateDeprecatedOptions` (validateCLIOptions.ts:68-70) as a `ValidationError` when a deprecated CLI option is used and the option is NOT in the allowed set (i.e. `opt.fatal === true`, computed at line 107). The thrown message is whatever the deprecation-entry function returns when called with `argv` - typically 'option X has been removed, use Y instead'.
Source
Thrown at packages/jest-validate/src/validateCLIOptions.ts:69
' Following options were not recognized:\n' +
` ${chalk.bold(format(unrecognizedOptions))}`;
}
return new ValidationError(title, message, comment);
};
const validateDeprecatedOptions = (
deprecatedOptions: Array<DeprecationItem>,
deprecationEntries: DeprecatedOptions,
argv: Config.Argv,
) => {
for (const opt of deprecatedOptions) {
const name = opt.name;
const message = deprecationEntries[name](argv);
const comment = DOCUMENTATION_NOTE;
if (opt.fatal) {
throw new ValidationError(name, message, comment);
} else {
logValidationWarning(name, message, comment);
}
}
};
export default function validateCLIOptions(
argv: Config.Argv,
options: Record<string, Options> & {
deprecationEntries?: DeprecatedOptions;
} = {},
rawArgv: Array<string> = [],
): boolean {
const yargsSpecialOptions = ['$0', '_', 'help', 'h'];
const allowedOptions = Object.keys(options).reduce(
(acc, option) =>
acc.add(option).add((options[option].alias as string) || option),View on GitHub (pinned to f49721c78e)
Solutions
- Read the message returned by the deprecation entry - it names the replacement.
- Replace the removed flag with its documented successor in your CLI invocation, npm scripts, and CI config.
- If unsure which flag triggered it, run with the args echoed (`node --inspect ... ` or a wrapper) and grep for the offending token.
- Pin to a Jest major where the flag still works only as a stopgap; migrate before the next major.
Example fix
# before: removed flag jest --runTestsByPath some/file.test.js # (hypothetical removed flag) # after jest path/to/file.test.js
Defensive patterns
Strategy: validation
Validate before calling
// Detect removed flags before invoking Jest
const { validateCLIOptions } = require('jest-validate');
try { validateCLIOptions(argv, registeredOptions, rawArgv); }
catch (e) { if (/ValidationError/.test(e.name)) suggestReplacement(e.message); throw e; } Try / catch
// Catch the validation, map to a helpful build error
try { runJest(args); }
catch (e) {
if (e.name === 'ValidationError' && /deprecated|removed|use instead/i.test(e.message))
throw new Error('CI script uses a removed Jest flag - ' + e.message);
throw e;
} Prevention
- After a Jest major bump, grep your CI/npm scripts for flags listed in the release notes as removed.
- Keep a single source of truth for the Jest CLI invocation and lint it on upgrade.
- Run `jest --help` after upgrade and reconcile against your scripts.
When it happens
Trigger: Passing a CLI flag that has been deprecated and is no longer in the current allowed-options set. Because `opt.fatal = !allowedOptions.has(arg)`, an option removed entirely from the registered yargs options triggers the throw; one merely deprecated but still registered only logs a warning.
Common situations: Upgrading Jest and using a removed CLI flag (e.g. `--jasmine` after jasmine was removed, `--runInBand` spelling changes, old `--config` shapes); passing aliases that were dropped; CI scripts that pin removed flags.
Related errors
- Option "${path}.${option}" must be of type: ${validTyp
- ${key} has to be of type string or number
- The shard option requires a string in the format of <n>/<m>.
- The shard option requires 1-based values, received 0 or lowe
- The shard option <n>/<m> requires <n> to be lower or equal t
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/3d6e4d269695c5f7.json.
Report an issue: GitHub.