Skip to content

Upgrading babel-jest 28 to 29

Breaking28.1.3 → 29.7.0Breaking11Security1Platform1New59Changed17Fixed97Other17

BreakingUpgrade verdict

11 breaking changes and a platform requirement change and a security fix.

  • Snapshot output changes by default: strings are no longer escaped and basic prototypes are not printed.
  • jest.mocked now deep-mocks by default, which can change what your mocks return.
  • The ANSI conversion plugin is gone; use the separate jest-serializer-ansi-escapes package instead.
  • Removes support for `weak-napi` in jest-leak-detector.
Top 5 of 13 that need code or config changes

Node.js requirement changed in 29.0.0-alpha.0: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0 → ^14.15.0 || ^16.10.0 || >=18.0.0.

Installs 139 packages in all (was 140).

Breaking11
Makes snapshotFormat default to escapeString: false and printBasicPrototype: false.
snapshotFormatescapeStringprintBasicPrototype
Changes the default jest.mocked helper behavior to deep mocked.
jest.mocked
Removes the ConvertAnsi plugin from pretty-format in favour of jest-serializer-ansi-escapes.
ConvertAnsijest-serializer-ansi-escapes
Removes support for weak-napi in jest-leak-detector.
weak-napi
Differentiates between MatcherContext, MatcherUtils and MatcherState types in expect.
MatcherContextMatcherUtilsMatcherState
Removes the undocumented collectCoverageOnlyFrom option.
collectCoverageOnlyFrom
Upgrades jest-environment-jsdom to jsdom@20.
jsdom
Refactors Mocked* utility types: MaybeMockedDeep and MaybeMocked become Mocked and MockedShallow; only deep variants of MockedClass, MockedFunction and MockedObject are exported.
MaybeMockedDeepMaybeMockedMockedMockedShallowMockedClassMockedFunctionMockedObject
Lets babel find config when updating inline snapshots.
babel
Requires rootDir as an argument to SnapshotState.
SnapshotStaterootDir
Replaces Bytes and Milliseconds types with number in @jest/test-result and @jest/types.
BytesMilliseconds
Security1
Updates the semver dependency to get a vulnerability fix.
semver
Platform1
Drops support for Node v12 and v17.