https://jestjs.io/blog/2022/04/25/jest-28
Jest 28 is finally here, and it comes with some long requested features such as support for sharding a test run across multiple machines, package exports
and the ability to customize the behavior of fake timers. These are just some personal highlights, and we'll be highlighting more in this blog post.
Additionally, as announced in the Jest 27 blog post last year, we have removed some packages that no longer are used by default from the default installation. As a result the installation size has dropped by about 1/3.
The list of breaking changes is long (and can be seen fully in the changelog), but for migration purposes, we've also written a guide you can follow. Hopefully this makes the upgrade experience as frictionless as possible!
Main breaking changes likely to impact your migration are dropped support for Node 10 and 15 (but not Node 12, which will be EOL in a few days) and some renamed configuration options.
Please note that both of the removed modules (jest-environment-jsdom
and jest-jasmine2
) are still actively maintained and tested in the same way, so the only breaking change here is that you'll need to explicitly install them.
The guide should hopefully make migration trivial, but note that if you use any of the packages Jest consists of directly (such as jest-worker
or pretty-format
), instead of just running jest
, then you need to go through the changelog to view any breaking changes.
Now let's talk about the new features in Jest 28, which is way more exciting! And there's quite a few of them, so buckle up.
Jest now includes a new --shard
CLI option, contributed by Mario Nebl. It allows you to run parts of your test across different machine, and has been one of Jest's oldest feature requests.
Jest's own test suite on CI went from about 10 minutes to 3 on Ubuntu, and on Windows from 20 minutes to 7.
package.json
exports
Jest shipped minimal support of exports
in 27.3. However, it only supported the "main" entry point (.
), and only if no main
field was present in package.json
. With Jest 28 we're excited to finally be shipping full support!
Related, in Jest 27, we provided either require
or import
condition. In Jest 28, jest-environment-node
will now automatically provide node
and node-addons
conditions, while jest-environment-jsdom
will provide the browser
condition.
This has been one of the biggest compatibility issues of Jest, and hopefully this is now resolved once and for all.
Jest 26 introduced the concept of "modern" fake timers, which uses @sinonjs/fake-timers
under the hood, and Jest 27 made it the default. In Jest 28, we are now exposing more of the underlying implementation through both configuration and runtime APIs. Huge thanks to Tom Mrazauskas who contributed this feature!