#6374·mocha

Bug: --t option for timeout does not work with mocha 12.0.1+. It used to work with mocha 11.7.5 and earlier.

Author: sharadrajuCreated Sep 22, 2026Updated Sep 29, 2026
Labelstype: bugstatus: in triage

Bug Report Checklist

Expected

With mocha 12.0.1 and beyond, when I run any test as npx mocha test/<test1.js> --t 0, I get an error:

  var err = new TypeError(message);
            ^

TypeError: Mocha flag '--t' given invalid option: '0'
    at createInvalidArgumentTypeError (...)
    at createErrorForNumericPositionalArg (...)
    at parseMochaArgs (...)
    at parse (...)
    at loadOptions (...)
    at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) {
  code: 'ERR_MOCHA_INVALID_ARG_TYPE',
  argument: 0,
  expected: 'string',
  actual: 'number'
}

Node.js v22.19.0

With earlier versions of mocha (11.7.6 and earlier), this used to run correctly and --t was accepted as a shortcut for the timeout switch.

Has this changed? Is this a regression or new feature?

Actual

With mocha 12.0.1 and beyond, when I run any test as npx mocha test/<test1.js> --t 0, I get an error:

  var err = new TypeError(message);
            ^

TypeError: Mocha flag '--t' given invalid option: '0'
    at createInvalidArgumentTypeError (...)
    at createErrorForNumericPositionalArg (...)
    at parseMochaArgs (...)
    at parse (...)
    at loadOptions (...)
    at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) {
  code: 'ERR_MOCHA_INVALID_ARG_TYPE',
  argument: 0,
  expected: 'string',
  actual: 'number'
}

Minimal, Complete and Verifiable Example

Run a simple mocha test with --t 0 flag npx mocha test/<test1.js> --t 0

Versions

mocha version 12.0.1+

Additional Info

No response