Replace usage of Jest globals with @jest/globals package #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempts to fix #116
Removed
@types/jest
package.Added
@jest/globals
as peer dependency. I'm not sure about which versions to support, but Jest 28 introduced a breaking change injest.Mock
type definition so I'm not confident how it would work with earlier versions.Note that this definition is different between
@types/jest@29
and@jest/globals@29
The change is described in jestjs/jest#12479
tl;dr the generic type is changed from
jest.fn<ReturnType<MyFunctionType>, Parameters<MyFunctionType>>
tojest.fn<MyFunctionType>
I did my best to fix the new type errors in the library but I had to add a couple of
// @ts-expect-error
comments in the process.The new types work across internal tests and when used as a dependency in our own repo but I'm not sure if they are valid for every existing use case for this library.