-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(expect): add
toSatisfy
asymmetric matcher (#7022)
- Loading branch information
Showing
7 changed files
with
158 additions
and
17 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,29 @@ | ||
import type { MatchersObject } from './types' | ||
|
||
// selectively ported from https://github.com/jest-community/jest-extended | ||
export const customMatchers: MatchersObject = { | ||
toSatisfy(actual: unknown, expected: (actual: unknown) => boolean, message?: string) { | ||
const { printReceived, printExpected, matcherHint } = this.utils | ||
const pass = expected(actual) | ||
return { | ||
pass, | ||
message: () => | ||
pass | ||
? `\ | ||
${matcherHint('.not.toSatisfy', 'received', '')} | ||
Expected value to not satisfy: | ||
${message || printExpected(expected)} | ||
Received: | ||
${printReceived(actual)}` | ||
: `\ | ||
${matcherHint('.toSatisfy', 'received', '')} | ||
Expected value to satisfy: | ||
${message || printExpected(expected)} | ||
Received: | ||
${printReceived(actual)}`, | ||
} | ||
}, | ||
} |
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
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
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
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
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
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