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 initmocha 1214 changes
Breaking changes 1
Nested tests now fail when a beforeEach hook fails.
New APIs and options 1
Supports one-character aliases using the --X form.
Fixes and other changes 12
Shows the require() error for unsupported directory imports.
Watch mode keeps running when the last test file is removed.
The detection window for --exit is widened.
Mocha works around ERR_PACKAGE_PATH_NOT_EXPORTED using find-up-simple.
The spec file path is propagated when a parallel worker dies.
A reporter option specified on the CLI takes precedence over the value in the config file.
Existing directories are watched so the first run starts armed.
Unknown configuration values are no longer treated as test specs.
Only positional arguments that are entirely numeric are rejected.
Embedded stacks render once after splitting err.stack at the trailing frame block.
Fixes parsing of negative numbers and quoted strings.
Preserves FIFO descriptors when respawning.
mocha 116 changes
Breaking changes 1
The engine range for Mocha 11 was adapted, changing the runtime requirement for developers.
New APIs and options 1
Adds an option to report skipped tests as failed.
Fixes and other changes 4
Mocha now surfaces ts-node compile errors so developers can see failures when compiling tests.
Fixed describe().timeout() so it works.
Mocha swallows more require errors from TypeScript files.
Hook methods can now be called.
mocha 107 changes
Breaking changes 6
AMD/RequireJS is no longer supported.
The executable was renamed from bin/mocha to bin/mocha.js.
Growl notifications are no longer supported.
Internet Explorer 11 is no longer supported.
Node.js v12.x is no longer supported.
The deprecated Runner signature was removed.
Fixes and other changes 1
The Minimatch upgrade affects the --ignore option on Windows.
mocha 97 changes
Breaking changes 2
Support for Node.js v10.x is dropped.
The deprecated
utils.lookupFiles()API is removed.
Deprecations 1
The
Runner(suite: Suite, delay: boolean)signature is deprecated.
New APIs and options 1
Adds the
--dry-runcommand-line option.
Behavior and default changes 2
The size of
actualandexpectedis limited when generating diffs.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.
Fixes and other changes 1
Fixes control over the stringification of error messages.
mocha 814 changes
Breaking changes 11
The context object's enableTimeout() method was removed; replace this.enableTimeout(false) with this.timeout(0).
The option throws an error even when exclusive tests are avoided via --grep or other means.
Mocha.prototype.hideDiff() was removed.
Mocha.prototype.ignoreLeaks() was removed.
The mocha.opts configuration file is no longer supported; replace it with a configuration file.
Mocha now requires Node.js v10.12.0 or newer.
Mocha drops support for the Node.js v13.x line.
Calling this.skip() in a before all hook no longer executes subsequent sibling hooks, as well as hooks in child suites.
The spec option no longer accepts a comma-delimited list of files; use an array instead.
Mocha.prototype.useColors() was removed.
Mocha.prototype.useInlineDiffs() was removed.
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.
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.
The option now works with ES modules.
mocha 722 changes
Breaking changes 14
The Node.js debug-related flag is removed.
The deprecated
getOptions()API is removed.This command-line option is replaced by
--list-interfaces.The
lib/cli/options.jsfile is removed.This command-line option replaces
--interfaces.This command-line option replaces
--reporters.The constructor's option names are aligned with command-line options.
Mocha no longer supports Node.js v6.x.
This command-line option is replaced by
--list-reporters.Conditionally skipping in a test now executes related
afterEachhooks.Conditionally skipping in a
beforeEachhook skips subsequent innerbeforeEachhooks and executes relatedafterEachhooks.Calling
this.skip()withinafterhooks is disallowed.An uncaught exception in a pending test is no longer swallowed; the test is retrospectively failed so the exit code is correct.
This watch-mode command-line option is removed.
Deprecations 2
The debug argument is deprecated.
Legacy configuration via
mocha.optsis soft-deprecated and emits a warning upon use.
New APIs and options 1
A new command-line option is added for watch mode.
Behavior and default changes 1
The constructor's browser setup is improved.
Tooling 1
Typing
rsfollowed by a newline restarts tests.
Fixes and other changes 3
The flag's interaction with
this.skip()is fixed.Timeout handling is fixed when using this flag.
The reporter now handles exceptions during diff generation.
mocha 648 changes
Breaking changes 14
Instantiating a Base-extending reporter without a Runner parameter now throws an exception.
When a before hook conditionally skips, subsequent before hooks and tests in nested suites are also skipped.
Invalid command-line argument usage now causes actual errors.
No longer supported; attempting to use it causes Mocha to fail with a link to more information.
Is no longer an alias for --debug and is currently ignored.
Debug-related flags such as --inspect imply --no-timeouts.
Alias for --watch-extensions; it also affects non-watch-mode test runs.
The option now fails fast when encountered on a suite.
Cannot be used together with --fgrep; attempting to use both now causes Mocha to fail.
The browser template has moved from lib/template.html to lib/browser/template.html.
Mocha now throws an exception if it cannot parse or find the file at a user-specified path.
Node.js v4.x is no longer supported.
No longer implies the js extension; add it explicitly when it is needed.
The reporter no longer duplicates test result numbers in errors and failures; failures will always be zero.
Deprecations 5
The exported function is soft-deprecated; use loadOptions or loadMochaOpts from lib/cli/options instead.
Soft-deprecated; use --gc-global instead. Use emits a warning.
The constructor option enableTimeouts is soft-deprecated; use timeout: false instead.
The constructor option useColors is soft-deprecated; use color: false instead.
Considered legacy; prefer an RC file or package.json.
New APIs and options 11
Specifies an explicit path to an RC configuration file.
Mocha adds in-browser notification support and warns about missing prerequisites when --growl is supplied.
Mocha's version can now be queried programmatically through this public property.
Prepending --no- to a Mocha-specific command-line flag negates that flag.
Disables configuration loading via an RC file.
Disables configuration loading via package.json.
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.
Specifies a package.json file from which to read the mocha property.
Mocha supports JavaScript, JSON, YAML, and package.json-based configuration using the mocha property; recognized RC filenames load automatically.
Mocha adds the ability to unload files from the require cache.
Runner emits a retry event when tests are retried, which reporters can listen for.
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.
Configurations are merged in priority order: command-line arguments, RC file, package.json, mocha.opts, then Mocha defaults.
Using --debug automatically invokes --inspect when supported by the running Node version.
Listed interfaces now include descriptions.
The reporter now emits error messages.
The reporter is now TAP13-capable.
Fixes and other changes 12
The regression that prevented after and after each hooks from executing has been fixed.
The option and other boolean options now work in all cases.
Tests with empty titles are no longer confused with the root suite.
Avoids noisy error messages when no test files are found.
Falsy values supplied through options globals are no longer mishandled.
The constructor now supports all options.
The --no-exit option is restored.
The option and --timeout 0 now behave as expected.
Reporter options now accept comma-separated options and key/value pairs.
Long-running tests now respect SIGINT.
Mocha no longer outputs color when TERM is dumb.
Exceptions include the filepath where applicable.
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.
New APIs and options 1
A new command-line argument is available for specifying files.
Fixes and other changes 2
Fixes bad markup produced by the HTML reporter.
Fixes inaccurate reporting of test durations.
mocha 410 changes
Breaking changes 4
Mocha drops Bower support; old versions remain available.
Mocha no longer supports Node.js 0.10.x, 0.11.x, 0.12.x, iojs, or 5.x.x.
Mocha no longer supports IE7, IE8, or PhantomJS 1.x.
Mocha no longer forces the process to exit when tests complete; use --exit to restore the previous behavior.
Deprecations 1
The command-line option is soft-deprecated and emits a warning on STDERR.
New APIs and options 1
The XUnit reporter allows overriding the default test suite name.
Behavior and default changes 3
Contexts are indented in failure reports for better readability.
Browser reporter logs no longer include the stdout: prefix.
A separator is added to unified diff output.
Fixes and other changes 1
A failure message is printed when --forbid-pending or --forbid-only is specified.