diff --git a/packages/expect/src/types.ts b/packages/expect/src/types.ts index 792a8b84a..0993110ee 100644 --- a/packages/expect/src/types.ts +++ b/packages/expect/src/types.ts @@ -92,7 +92,7 @@ export interface RawMatcherFn { export type MatchersObject = Record< string, RawMatcherFn -> +> & ThisType export interface ExpectStatic extends Chai.ExpectStatic, diff --git a/test/core/test/jest-expect.test.ts b/test/core/test/jest-expect.test.ts index 93566aec3..8d4c9cbf3 100644 --- a/test/core/test/jest-expect.test.ts +++ b/test/core/test/jest-expect.test.ts @@ -246,6 +246,15 @@ describe('jest-expect', () => { message: () => '', } }, + toBeTestedMatcherContext(received: unknown, expected: T) { + if (typeof this.utils?.stringify !== 'function') { + throw new TypeError('this.utils.stringify is not available.') + } + return { + pass: received === expected, + message: () => 'toBeTestedMatcherContext', + } + }, }) expect(5).toBeDividedBy(5)