Mocha v4.0.0 is nearing release. With this new version also comes the obligatory breaking changes, and I'll enumerate them below.
Mocha Will No Longer Support Node.js Pre-v4.0.0
There are several reasons for this:
- These versions of Node.js are no longer maintained and (some) have known security vulnerabilities which will not receive official patches. Users of these versions should upgrade Node.js. For example, v0.10.0 and v0.12.0 have been end-of-lifed since October and December 2016, respectively.
- Mocha's own dependencies have already dropped support for these platforms, and so Mocha cannot address to security vulnerabilities or critical bug fixes in reasonable manner nor timeframe.
- Mocha's development environment can no longer run out-of-the-box in a pre-v4.0.0 environment.
The following unmaintained versions of Node.js will no longer be supported by Mocha:
Node.js v5.x is likely to work as long as Node.js v4.x does, but will not be in Mocha's build matrix.
It's important to note that Mocha v3.x will still work on these platforms, but users can no longer expect upgrades.
The above change also means:
Mocha Will No Longer Support
npm Older Than v2.15.11
npmv2.15.11 is the version which shipped with Node.js v4.0.0.
- Even older versions didn't support scoped packages (
@foo/bar), nor the caret (
^) semver range specifier. This made it virtually impossible to include production dependencies which used either of these features.
Users are encouraged to upgrade to the latest version of
Users of Bower are also encouraged to upgrade, because:
Mocha Will No Longer Support Bower
This may or may not make it into v4.
Bower is an excellent tool to install front-end dependencies. However, over the years, more robust solutions have evolved. Its time has passed.
Mocha v4 will remove its "browser bundle" (
mocha.js) from version control. This means
bower will not install Mocha v4 out-of-the-box. There may be a workaround by means of a "resolver", but YMMV.
A Warning To Those Bundling Mocha
This change may also impact those users bundling Mocha themselves via
webpack, etc. The
browser field will now point to
mocha.js, which is already bundled. You may no longer need to bundle yourself, or you may need to find a different way to do it. If you cannot find a reasonable workaround, please open an issue on our tracker.
Finally, my favorite:
Mocha Will No Longer Support Non-ES5-Compliant Environments
Mocha is likely the last major actively maintained testing framework to officially support these browsers.
While Mocha's maintainers have proudly sustained the poor, piteous developers who have such business (or government!) requirements, the overhead of retaining compatibility has become an albatross.
Much like supporting older versions of Node.js, this has severely limited the project's agility. Mocha should shed some weight after this, as it contains a plethora of handrolled shims.
The following browser environments will no longer be supported in Mocha v4:
- Internet Explorer 7
- Internet Explorer 8
- PhantomJS 1.x
API and output changes follow.
Other Breaking Changes
Read this to save yourself some time.
Mocha Won't Force Exit
This may or may not make it into v4.
To avoid false positives and encourage better testing practices, Mocha will no longer automatically kill itself via
process.exit() when it thinks it should be done running.
mocha process is still alive after your tests seem "done", then your tests have scheduled something to happen (asynchronously) and haven't cleaned up after themselves properly. Did you leave a socket open?
--exit flag to use pre-v4 behavior.
If you're having trouble figuring out where the hangup is, this package might help.
There will be a few changes to reporters, which may negatively affect projects consuming Mocha's output directly:
- The "unified diff" will now contain separators, as it has been difficult to read.
- Upon error, the test contexts will be indented instead of smooshed into a single line.