-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat(expect): replace RawMatcherFn with MatcherFunction and MatcherFunctionWithState types
#12376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
3d31e39
2273adf
47bca7f
3064a78
eafcbc2
f97e5a8
f0407fc
b16b3a4
71d8de1
ab8c2ea
f0bca5d
3023e88
4589553
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
|
|
||
| /* eslint-disable local/prefer-spread-eventually */ | ||
|
|
||
| import {type MatcherState, type RawMatcherFn, expect} from 'expect'; | ||
| import {type MatcherState, expect} from 'expect'; | ||
| import { | ||
| addSerializer, | ||
| toMatchInlineSnapshot, | ||
|
|
@@ -41,23 +41,15 @@ export default function jestExpect(config: {expand: boolean}): void { | |
| jestMatchersObject[name] = function ( | ||
| this: MatcherState, | ||
| ...args: Array<unknown> | ||
| ): RawMatcherFn { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
| ) { | ||
| // use "expect.extend" if you need to use equality testers (via this.equal) | ||
| const result = jasmineMatchersObject[name](null, null); | ||
| // if there is no 'negativeCompare', both should be handled by `compare` | ||
| const negativeCompare = result.negativeCompare || result.compare; | ||
|
|
||
| return this.isNot | ||
| ? negativeCompare.apply( | ||
| null, | ||
| // @ts-expect-error | ||
| args, | ||
| ) | ||
| : result.compare.apply( | ||
| null, | ||
| // @ts-expect-error | ||
| args, | ||
| ); | ||
| ? negativeCompare.apply(null, args) | ||
| : result.compare.apply(null, args); | ||
| }; | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
|
|
||
| import type {AssertionError} from 'assert'; | ||
| import type {Config} from '@jest/types'; | ||
| import type {Expect, RawMatcherFn} from 'expect'; | ||
| import type {Expect, ExpectationResult} from 'expect'; | ||
| import type CallTracker from './jasmine/CallTracker'; | ||
| import type Env from './jasmine/Env'; | ||
| import type JsApiReporter from './jasmine/JsApiReporter'; | ||
|
|
@@ -48,8 +48,8 @@ export interface Spy extends Record<string, any> { | |
|
|
||
| type JasmineMatcher = { | ||
| (matchersUtil: unknown, context: unknown): JasmineMatcher; | ||
| compare: () => RawMatcherFn; | ||
| negativeCompare: () => RawMatcherFn; | ||
| compare(...args: Array<unknown>): ExpectationResult; | ||
| negativeCompare(...args: Array<unknown>): ExpectationResult; | ||
|
||
| }; | ||
|
|
||
| export type JasmineMatchersObject = {[id: string]: JasmineMatcher}; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.