Upgrading @jest/globals 26 to 27
Breaking26.6.2 → 27.5.1Breaking52Platform2Deprecated1New56Changed24Fixed99Other18
BreakingUpgrade verdict
52 breaking changes and 2 platform requirement changes.
In plain terms
- Fake timers now use the modern implementation by default.
- When resolving files, .json is now tried after .ts and .tsx instead of before them.
- jsdom tests no longer have setImmediate and clearImmediate available as globals.
- Three old Jest APIs that were deprecated for a long time are gone.
Must act Top 5 of 55 that need code or config changes
Node.js requirement changed in 27.0.0-next.0: >= 10.14.2 → ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0.
Installs 47 packages in all (was 48).
What you must change
Breaking52
Uses the modern implementation as the default for fake timers.
fakeTimersjest-configjest-runtimeChanges the default file extension order by moving json behind ts and tsx.
jest-configRemoves Node globals setImmediate and clearImmediate from jest-environment-jsdom.
setImmediateclearImmediateRemoves long-deprecated jest.addMatchers, jest.resetModuleRegistry, and jest.runTimersToTime.
jest.addMatchersjest.resetModuleRegistryjest.runTimersToTimeRemoves the deprecated mapCoverage option.
mapCoverageRemoves the enabledTestsMap config in favor of filter.
enabledTestsMapfilterRemoves support for the deprecated ignorePattern option as a function.
ignorePatternRemoves the unused options argument from the Env constructor in jest-jasmine2.
EnvRemoves the deprecated and unused getSourceMapInfo from Runtime.
RuntimegetSourceMapInfoRemoves the unused isCoreModule option from jest-transformer.
isCoreModulejest-transformerRemoves the recursiveBlacklist option in favor of recursiveDenylist in jest-validate.
recursiveBlacklistrecursiveDenylistjest-config defaults to the Node testing environment instead of browser (JSDOM).
testEnvironmentjest-configjest-config uses jest-circus as the default test runner.
jest-circustestRunnerjest-configAdds a custom HasteMap class implementation config option.
HasteMapjest-haste-mapjest-configRuns transforms over the environment in jest-repl and jest-runner.
Runs transforms over runner in jest-runner.
Runs transforms over testRunner in jest-runner.
testRunnerMakes prettier optional for inline snapshots, falling back to string replacement.
prettierRuns transforms over snapshotResolver in jest-snapshot.
snapshotResolverStops exporting ScriptTransformer class and instead exports async function createScriptTransformer.
ScriptTransformercreateScriptTransformerrequireAndTranspileModule always returns a Promise and its third parameter is now RequireAndTranspileModuleOptions.
requireAndTranspileModuleRequireAndTranspileModuleOptionsapplyInteropRequireDefaultcreateTranspilingRequire now returns a function that returns a Promise.
createTranspilingRequireRevises expect.not.objectContaining() to be the inverse of expect.objectContaining(), as documented.
expect.not.objectContaining()expect.objectContaining()Makes toContain more strict about the received type.
toContainmatcherResult on JestAssertionError is now strings rather than functions.
matcherResultJestAssertionErrorUses only named exports in jest-diff.
jest-diffIgnores excess words in jest-each headings.
jest-eachDrops support for runScript for test environments.
runScriptConverts jest-get-type to an ES Module.
jest-get-typeStops injecting the global variable into the module wrapper.
globalRefactors the transform API to pass an options bag instead of multiple boolean options.
Refactors transformer API to pass an options bag rather than separate config and other options.
configSwitches jest-worker to named exports.
Converts pretty-format to ES Modules.
pretty-formatAdds an exports field to all package.json files.
exportsMigrates babel-jest to ESM.
babel-jestReplaces the TestScheduler export with createTestScheduler.
TestSchedulercreateTestSchedulerMoves root into config and makes GlobalConfig a mandatory parameter for getConsoleOutput.
rootconfigGlobalConfiggetConsoleOutputMigrates jest-haste-map to ESM.
jest-haste-mapMigrates jest-jasmine2 to ESM.
jest-jasmine2Moves the jest-runtime CLI into jest-repl.
jest-runtimejest-replMigrates jest-resolve to ESM.
jest-resolveMigrates jest-resolve-dependencies to ESM.
jest-resolve-dependenciesMakes node-notifier a peer dependency of jest-reporters.
node-notifierjest-reportersUses Maps instead of objects for all cached resources in jest-resolve and jest-runtime.
jest-resolvejest-runtimeMapMigrates jest-runner to ESM.
jest-runnerjest-circus now fails tests when multiple done() calls are made.
done()jest-circusjest-circus and jest-jasmine2 fail the test instead of warning when describe returns a value.
describejest-circusjest-jasmine2Sets exit code to 1 if test logs after teardown in jest-runner.
Disallows return values other than a Promise from hooks and tests.
PromiseDisallows mixing a done callback and returning a Promise from hooks and tests.
donePromiseMigrates jest-mock to ESM.
jest-mockPlatform2
Allows node-notifier@10 as a peer dependency of @jest/reporters.
node-notifierDrops support for non-LTS Node versions, supporting only Node LTS releases and Node 15.
Deprecations to plan for
Deprecated1
Marks deprecated configuration options as @deprecated in @jest/types.
@deprecated