unstale

npm / mocha

mocha

What changed in mocha 4 to 12, from its official release notes, upgrade guides and advisories. Also covers @types/mocha. Sources checked 2026-11-30.

54 breaking9 deprecations18 new APIs and options14 behavior and defaults1 tooling36 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

mocha 1214 changes

Breaking changes 1

  • Nested tests now fail when a beforeEach hook fails.

    12.0.2release notes

New APIs and options 1

  • Supports one-character aliases using the --X form.

    12.0.3release notes

Fixes and other changes 12

  • Shows the require() error for unsupported directory imports.

    12.0.3release notes

  • Watch mode keeps running when the last test file is removed.

    12.0.3release notes

  • The detection window for --exit is widened.

    12.0.2release notes

  • Mocha works around ERR_PACKAGE_PATH_NOT_EXPORTED using find-up-simple.

    12.0.2release notes

  • The spec file path is propagated when a parallel worker dies.

    12.0.2release notes

  • A reporter option specified on the CLI takes precedence over the value in the config file.

    12.0.2release notes

  • Existing directories are watched so the first run starts armed.

    12.0.2release notes

  • Unknown configuration values are no longer treated as test specs.

    12.0.1release notes

  • Only positional arguments that are entirely numeric are rejected.

    12.0.1release notes

  • Embedded stacks render once after splitting err.stack at the trailing frame block.

    12.0.1release notes

  • Fixes parsing of negative numbers and quoted strings.

    12.0.0release notes

  • Preserves FIFO descriptors when respawning.

    12.0.0release notes

mocha 116 changes

Breaking changes 1

  • The engine range for Mocha 11 was adapted, changing the runtime requirement for developers.

    11.0.0release notes

New APIs and options 1

  • Adds an option to report skipped tests as failed.

    11.8.0release notes

Fixes and other changes 4

  • Mocha now surfaces ts-node compile errors so developers can see failures when compiling tests.

    11.7.7release notes

  • Fixed describe().timeout() so it works.

    11.7.6release notes

  • Mocha swallows more require errors from TypeScript files.

    11.7.5release notes

  • Hook methods can now be called.

    11.0.0release notes

mocha 107 changes

Breaking changes 6

Fixes and other changes 1

  • The Minimatch upgrade affects the --ignore option on Windows.

    10.0.0release notes

mocha 97 changes

Breaking changes 2

Deprecations 1

  • The Runner(suite: Suite, delay: boolean) signature is deprecated.

    9.0.0release notes

New APIs and options 1

Behavior and default changes 2

  • The size of actual and expected is limited when generating diffs.

    9.0.0release notes

  • Mocha loads test files with ESM import first, falling back to require when import fails; this allows ESM loaders to load and transform test files.

    9.0.0release notes

Fixes and other changes 1

  • Fixes control over the stringification of error messages.

    9.0.0release notes

mocha 814 changes

Breaking changes 11

  • The context object's enableTimeout() method was removed; replace this.enableTimeout(false) with this.timeout(0).

    8.0.0release notes

  • The option throws an error even when exclusive tests are avoided via --grep or other means.

    8.0.0release notes

  • Mocha.prototype.hideDiff() was removed.

    8.0.0release notes

  • Mocha.prototype.ignoreLeaks() was removed.

    8.0.0release notes

  • The mocha.opts configuration file is no longer supported; replace it with a configuration file.

    8.0.0release notes

  • Mocha now requires Node.js v10.12.0 or newer.

    8.0.0release notes

  • Mocha drops support for the Node.js v13.x line.

    8.0.0release notes

  • Calling this.skip() in a before all hook no longer executes subsequent sibling hooks, as well as hooks in child suites.

    8.0.0release notes

  • The spec option no longer accepts a comma-delimited list of files; use an array instead.

    8.0.0release notes

  • Mocha.prototype.useColors() was removed.

    8.0.0release notes

  • Mocha.prototype.useInlineDiffs() was removed.

    8.0.0release notes

New APIs and options 1

  • Mocha adds the ability to run tests in parallel for Node.js; root hooks must be defined via Root Hook Plugins to work in parallel mode.

    8.0.0release notes

Behavior and default changes 2

  • In some circumstances, Mocha can run ES modules under Node.js v10; this is described as use at your own risk.

    8.0.0release notes

  • The option now works with ES modules.

    8.0.0release notes

mocha 722 changes

Breaking changes 14

  • The Node.js debug-related flag is removed.

    7.0.0release notes

  • The deprecated getOptions() API is removed.

    7.0.0release notes

  • This command-line option is replaced by --list-interfaces.

    7.0.0release notes

  • The lib/cli/options.js file is removed.

    7.0.0release notes

  • This command-line option replaces --interfaces.

    7.0.0release notes

  • This command-line option replaces --reporters.

    7.0.0release notes

  • The constructor's option names are aligned with command-line options.

    7.0.0release notes

  • Mocha no longer supports Node.js v6.x.

    7.0.0release notes

  • This command-line option is replaced by --list-reporters.

    7.0.0release notes

  • Conditionally skipping in a test now executes related afterEach hooks.

    7.0.0release notes

  • Conditionally skipping in a beforeEach hook skips subsequent inner beforeEach hooks and executes related afterEach hooks.

    7.0.0release notes

  • Calling this.skip() within after hooks is disallowed.

    7.0.0release notes

  • An uncaught exception in a pending test is no longer swallowed; the test is retrospectively failed so the exit code is correct.

    7.0.0release notes

  • This watch-mode command-line option is removed.

    7.0.0release notes

Deprecations 2

  • The debug argument is deprecated.

    7.0.0release notes

  • Legacy configuration via mocha.opts is soft-deprecated and emits a warning upon use.

    7.0.0release notes

New APIs and options 1

  • A new command-line option is added for watch mode.

    7.0.0release notes

Behavior and default changes 1

Tooling 1

  • Typing rs followed by a newline restarts tests.

    7.0.0release notes

Fixes and other changes 3

  • The flag's interaction with this.skip() is fixed.

    7.0.0release notes

  • Timeout handling is fixed when using this flag.

    7.0.0release notes

  • The reporter now handles exceptions during diff generation.

    7.0.0release notes

mocha 648 changes

Breaking changes 14

  • Instantiating a Base-extending reporter without a Runner parameter now throws an exception.

    6.0.0release notes

  • When a before hook conditionally skips, subsequent before hooks and tests in nested suites are also skipped.

    6.0.0release notes

  • Invalid command-line argument usage now causes actual errors.

    6.0.0release notes

  • No longer supported; attempting to use it causes Mocha to fail with a link to more information.

    6.0.0release notes

  • Is no longer an alias for --debug and is currently ignored.

    6.0.0release notes

  • Debug-related flags such as --inspect imply --no-timeouts.

    6.0.0release notes

  • Alias for --watch-extensions; it also affects non-watch-mode test runs.

    6.0.0release notes

  • The option now fails fast when encountered on a suite.

    6.0.0release notes

  • Cannot be used together with --fgrep; attempting to use both now causes Mocha to fail.

    6.0.0release notes

  • The browser template has moved from lib/template.html to lib/browser/template.html.

    6.0.0release notes

  • Mocha now throws an exception if it cannot parse or find the file at a user-specified path.

    6.0.0release notes

  • Node.js v4.x is no longer supported.

    6.0.0release notes

  • No longer implies the js extension; add it explicitly when it is needed.

    6.0.0release notes

  • The reporter no longer duplicates test result numbers in errors and failures; failures will always be zero.

    6.0.0release notes

Deprecations 5

  • The exported function is soft-deprecated; use loadOptions or loadMochaOpts from lib/cli/options instead.

    6.0.0release notes

  • Soft-deprecated; use --gc-global instead. Use emits a warning.

    6.0.0release notes

  • The constructor option enableTimeouts is soft-deprecated; use timeout: false instead.

    6.0.0release notes

  • The constructor option useColors is soft-deprecated; use color: false instead.

    6.0.0release notes

  • Considered legacy; prefer an RC file or package.json.

    6.0.0release notes

New APIs and options 11

  • Specifies an explicit path to an RC configuration file.

    6.0.0release notes

  • Mocha adds in-browser notification support and warns about missing prerequisites when --growl is supplied.

    6.0.0release notes

  • Mocha's version can now be queried programmatically through this public property.

    6.0.0release notes

  • Prepending --no- to a Mocha-specific command-line flag negates that flag.

    6.0.0release notes

  • Disables configuration loading via an RC file.

    6.0.0release notes

  • Disables configuration loading via package.json.

    6.0.0release notes

  • The mocha executable supports allowed Node flags and V8 flags prefixed with --v8-; flags are also supported in configuration files, package.json properties, and mocha.opts.

    6.0.0release notes

  • Specifies a package.json file from which to read the mocha property.

    6.0.0release notes

  • Mocha supports JavaScript, JSON, YAML, and package.json-based configuration using the mocha property; recognized RC filenames load automatically.

    6.0.0release notes

  • Mocha adds the ability to unload files from the require cache.

    6.0.0release notes

  • Runner emits a retry event when tests are retried, which reporters can listen for.

    6.0.0release notes

Behavior and default changes 6

  • Exceptions thrown from Mocha's programmatic API now have a code property; check it instead of message to identify error types.

    6.0.0release notes

  • Configurations are merged in priority order: command-line arguments, RC file, package.json, mocha.opts, then Mocha defaults.

    6.0.0release notes

  • Using --debug automatically invokes --inspect when supported by the running Node version.

    6.0.0release notes

  • Listed interfaces now include descriptions.

    6.0.0release notes

  • The reporter now emits error messages.

    6.0.0release notes

  • The reporter is now TAP13-capable.

    6.0.0release notes

Fixes and other changes 12

  • The regression that prevented after and after each hooks from executing has been fixed.

    6.0.0release notes

  • The option and other boolean options now work in all cases.

    6.0.0release notes

  • Tests with empty titles are no longer confused with the root suite.

    6.0.0release notes

  • Avoids noisy error messages when no test files are found.

    6.0.0release notes

  • Falsy values supplied through options globals are no longer mishandled.

    6.0.0release notes

  • The constructor now supports all options.

    6.0.0release notes

  • The --no-exit option is restored.

    6.0.0release notes

  • The option and --timeout 0 now behave as expected.

    6.0.0release notes

  • Reporter options now accept comma-separated options and key/value pairs.

    6.0.0release notes

  • Long-running tests now respect SIGINT.

    6.0.0release notes

  • Mocha no longer outputs color when TERM is dumb.

    6.0.0release notes

  • Exceptions include the filepath where applicable.

    6.0.0release notes

mocha 54 changes

Breaking changes 1

  • Mocha drops support for IE9 and IE10; code consuming the userland buffer module through bundling or otherwise may be affected.

    5.0.0release notes

New APIs and options 1

  • A new command-line argument is available for specifying files.

    5.0.0release notes

Fixes and other changes 2

mocha 410 changes

Breaking changes 4

  • Mocha drops Bower support; old versions remain available.

    4.0.0release notes

  • Mocha no longer supports Node.js 0.10.x, 0.11.x, 0.12.x, iojs, or 5.x.x.

    4.0.0release notes

  • Mocha no longer supports IE7, IE8, or PhantomJS 1.x.

    4.0.0release notes

  • Mocha no longer forces the process to exit when tests complete; use --exit to restore the previous behavior.

    4.0.0release notes

Deprecations 1

  • The command-line option is soft-deprecated and emits a warning on STDERR.

    4.0.0release notes

New APIs and options 1

  • The XUnit reporter allows overriding the default test suite name.

    4.0.0release notes

Behavior and default changes 3

  • Contexts are indented in failure reports for better readability.

    4.0.0release notes

  • Browser reporter logs no longer include the stdout: prefix.

    4.0.0release notes

  • A separator is added to unified diff output.

    4.0.0release notes

Fixes and other changes 1

  • A failure message is printed when --forbid-pending or --forbid-only is specified.

    4.0.0release notes