When we started rebuilding Jest five years ago our goal was to provide a batteries-included zero-configuration test runner that is approachable for beginners, extensible for almost all testing use cases and scalable to large projects. One of the instrumental releases was Jest 15 which tied everything together and provided good defaults that allowed people to run Jest often without any setup. However, this approach has a big downside as Jest installs a lot of dependencies into your projects that you may not need.
We are now beginning to address this shortcoming and are working on reducing Jest’s install size while keeping it approachable and extensible. We have made the following breaking changes in Jest 26:
[expect, jest-mock, pretty-format]Remove
ES5build files with a new minimum of support of ES2015 (Node 8) which were only used for browser builds (#9945)
Migration: With this change, we are pushing the responsibility to bundle the affected packages to the users, rather than Jest providing them out of the box, since they know their target environments best. If you want it back, we're open to shipping these as separate packages. PRs welcome!
[jest-config, jest-resolve]Remove support for
browser-resolvemodule and use the following configuration:
const browserResolve = require('browser-resolve');
module.exports = browserResolve.sync;
TypeScript definitions requires a minimum of TypeScript v3.8 (#9823)
With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 MiB). Please keep in mind that many dependencies like Babel are likely already part of your project. Jest's own size was reduced by 1.2 MiB (4.3 -> 3.1 MiB).
While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by up to 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a “Tick-Tock" release process:
- Jest 27 will ship with a new test runner "
jest-circus" and the Node.js environment by default.
jest-environment-jsdomwill still be bundled so users can keep using them by changing one-line each in the configuration.
- Jest 28 will remove
jest-environment-jsdomfrom the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them.
Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new defaults now, and your project does not require a DOM environment, you can upgrade to Jest 26 and add the following configuration options: