-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(sanity): add workaround for typing difference between @types/je…
…st and @jest/globals
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// eslint-disable-next-line import/no-unassigned-import | ||
import '@jest/expect' | ||
|
||
declare module '@jest/expect' { | ||
interface Matchers<R extends void | Promise<void>> { | ||
/** | ||
* Used to check that a JavaScript object matches a subset of the properties of an object | ||
* | ||
* Works around an issue that surfaced after moving from jest types provided by `@types/jest` to the ones provided by `@jest/globals` | ||
* The `toMatchObject` typing from `@types/jest` allows for any value to be passed as the expected value, but the one from | ||
* `@jest/globals`, which comes from the types defined in the `expect` package, is stricter, only allowing for records or arrays of records | ||
* and doesn't allow arrays of arrays, for example. | ||
* | ||
* For comparison: | ||
* - `@types/jest`: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b0a62b6f70772fc34ef27affdcfc350ae7556916/types/jest/index.d.ts#L1078C9-L1078C61 | ||
* - `@jest/globals`/`expect`: https://github.com/jestjs/jest/blob/2178fa2183cb7cb2ac3e262388499bafd032ef03/packages/expect/src/types.ts#L299 | ||
* | ||
*/ | ||
toMatchObject(expected: object): R | ||
} | ||
} |