Today we're announcing a switch to major revisions for Jest with Jest 11.0 being the first major release. Jest has been used by Facebook engineers and on our continuous integration systems for years and we believe Jest has been way beyond a “1.0 release” for a long time. This is similar to a change the React team has made.
If you are using Jest 0.9 or Jest 0.10 the upgrade should be seamless. All changes from the last few months were rolled into Jest 11.0.
New in Jest 11.0
Babel Integration and Simplified Setup
babel-jest was adopted within the newly modularized Jest repository and it is now seamlessly integrated into Jest. If you are upgrading from an older version of Jest or are looking to adopt Jest, we recommend reading the Getting Started guide.
Previously Jest provided APIs such as
jest.dontMock which unmocks a module that is subsequently being required using the
require function. Testing code usually looked like this:
const LikeButton = require('LikeButton'); // LikeButton is unmocked
However, together with ES2015 import statements this will no longer work. Per the specification
imports are hoisted to the top of their code block. Code written like this:
import LikeButton from 'LikeButton';
when executed, would actually be run in this order:
import LikeButton from 'LikeButton'; // This happens before the dontMock call.
The LikeButton module would therefore be mocked even though we explicitly call
When the latest versions of Jest and babel-jest are used together, calls to the new APIs
jest.enableAutomock are hoisted to the top of their block, before ES2015 import statements.
import LikeButton from 'LikeButton'; // LikeButton is properly unmocked!