4.0.0
Highlights
jest-whenis now authored in TypeScript- fixes a number of long-standing typing issues, especially around wrapper mocks,
calledWithinference, andvoid/Promise<void>cases - compatibility is now verified in both Jest 29 and Jest 27 environments
What changed
Native TypeScript source
The library source has been migrated from JavaScript to TypeScript, with the public type contract now tested directly in the repo.
Stronger, more accurate typings
This release tightens a number of important typing behaviors:
calledWith/expectCalledWithpreserve argument tuple types againmockReturnValue/mockResolvedValue/ related methods track the mocked function's return type much more accuratelyvoid/Promise<void>cases allow omitted values correctly- better support for function-like wrapper mocks, including
jest-mock-extended-style mocked object methods - typed casts, mocked module functions, spies, optional args, rest args,
allArgs, and matcher cases are now covered by contract tests
Compatibility guardrails
The repo now has:
- a primary Jest 29 development environment
- a dedicated
compat/jest27workspace
The full build, runtime tests, and type tests run in both environments. This was added specifically to avoid fixing newer Jest/mock ecosystems while regressing older supported ones.
Breaking changes
- minimum supported Jest version is now 27
- TypeScript usages that previously compiled because the old typings were too loose may now fail typechecking
There are no intentional runtime API changes in this release.
Thanks
Thanks to @tlevesque-ueat for the repros, patience, and repeated validation while this got sorted out.