mochajs/mocha · error · TypeError
ERR_MOCHA_INVALID_ARG_TYPE
ERR_MOCHA_INVALID_ARG_TYPE
Error message
Mocha flag '${flag}' given invalid option: '${numericArg}' What it means
Error "Mocha flag '${flag}' given invalid option: '${numericArg}'" thrown in mochajs/mocha.
Source
Thrown at lib/cli/parse-args.js:364
numericArg,
allArgs,
parsedResult,
) => {
// A flag for `numericArg` exists if:
// 1. A Mocha flag immediately preceded the numericArg in `allArgs`, and
// 2. parseArgs() could not assign the numericArg to that flag because the
// option has an incompatible datatype.
const flag = allArgs.find((arg, index) => {
const normalizedArg = stripLeadingDashes(arg);
return (
isMochaFlag(arg) &&
allArgs[index + 1] === String(numericArg) &&
parsedResult[normalizedArg] !== String(numericArg)
);
});
if (flag) {
throw createInvalidArgumentTypeError(
`Mocha flag '${flag}' given invalid option: '${numericArg}'`,
numericArg,
expectedTypeForFlag(flag),
);
}
throw createUnsupportedError(
`Option ${numericArg} is unsupported by the mocha cli`,
);
};
/**
* Parse the args into a config object.
* Splits,
* handles Node args,
* validates general args,
* parses into config object,
* normalizes,View on GitHub (pinned to 6bcbee4fd9)
When it happens
Trigger: Thrown at lib/cli/parse-args.js:364 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mochajs/mocha@6bcbee4fd9 (2026-09-01).
Data as JSON: /api/errors/e156c31760481556.
Report an issue: GitHub.