Skip to content

Upgrading mocha 11 to 12

Breaking11.8.0 → 12.0.3Breaking11Platform1New7Changed33Fixed39Other275

BreakingUpgrade verdict

11 breaking changes and a platform requirement change.

  • The internal launcher script is gone and the package's entry points are now ES modules, which can break setups that relied on the old CommonJS layout.
  • Some old helper functions in the errors module are gone, so code importing them will break.
  • Mocha no longer supports running tests on Sauce Labs.
  • The old --compilers command-line option is no longer mentioned anywhere in Mocha.
Top 4 of 12 that need code or config changes

Node.js requirement changed in 12.0.0-alpha-issue-5899.1: ^18.18.0 || ^20.9.0 || >=21.1.0 → ^20.19.0 || >=22.12.0.

Adds find-up-simple ^1.0.1, is-unicode-supported ^0.1.0.

Drops escape-string-regexp, find-up, he, log-symbols, yargs, yargs-parser, yargs-unparser.

Installs 24 packages in all (was 93).

No longer installs @isaacs/cliui, @pkgjs/parseargs, ansi-regex, ansi-styles, camelcase, chalk, cliui, color-convert, color-name, cross-spawn, decamelize, eastasianwidth, emoji-regex, escalade, flat and 24 more.

Moves argparse 2.0.1 → 3.0.4, balanced-match 1.0.2 → 4.0.4, brace-expansion 2.1.7 → 5.0.12, chokidar 4.0.3 → 5.0.0, diff 7.0.0 → 9.0.0, glob 10.5.0 → 13.0.6, is-path-inside 3.0.3 → 4.0.0, js-yaml 4.3.2 → 5.5.0, lru-cache 10.4.3 → 11.5.3, minimatch 9.0.9 → 10.2.6, path-scurry 1.11.1 → 2.0.2, readdirp 4.1.2 → 5.1.1, serialize-javascript 6.0.2 → 7.1.4, strip-json-comments 3.1.1 → 5.0.3, supports-color 7.2.0, 8.1.1 → 8.1.1 and 1 more. Your build may pick other versions.

Breaking11
Removes bin/_mocha and converts bin/ and entry points to ESM.
bin/_mocha
Removes unused legacy functions from errors.js.
errors.js
Removes Sauce Labs support.
Removes references to the deprecated --compilers option.
--compilers
Removes references to the deprecated --opts option.
--opts
Changes the default of --forbid-only to check for process.env.CI.
--forbid-onlyprocess.env.CI
Replaces yargs with Node.js util.parseArgs for command-line argument parsing.
util.parseArgsyargs
Replaces yargs-parser in CLI option loading, which may change how CLI options are parsed.
yargs-parser
Replaces yargs-unparser in CLI respawn paths, which may change how options are re-serialized for child processes.
yargs-unparser
Replaces the he dependency with manual HTML encoding.
he
Changes the root package.json type to module, making the package ESM.
Platform1
Bumps the minimum Node.js version from 18.18.0 to 20.19.0.