mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 20:21:46 +00:00
Merge pull request #30009 from CarsonF/bugfix/jest-extend
[Jest] - Fix returning message as string for custom matchers
This commit is contained in:
Vendored
+8
-1
@@ -345,7 +345,14 @@ declare namespace jest {
|
||||
}
|
||||
|
||||
interface ExpectExtendMap {
|
||||
[key: string]: (this: MatcherUtils, received: any, ...actual: any[]) => { message(): string | (() => string), pass: boolean } | Promise<{ message(): string, pass: boolean }>;
|
||||
[key: string]: CustomMatcher;
|
||||
}
|
||||
|
||||
type CustomMatcher = (this: MatcherUtils, received: any, ...actual: any[]) => CustomMatcherResult | Promise<CustomMatcherResult>;
|
||||
|
||||
interface CustomMatcherResult {
|
||||
pass: boolean;
|
||||
message: string | (() => string);
|
||||
}
|
||||
|
||||
interface SnapshotSerializerOptions {
|
||||
|
||||
@@ -433,6 +433,14 @@ expect.extend({
|
||||
};
|
||||
}
|
||||
});
|
||||
expect.extend({
|
||||
foo(this: jest.MatcherUtils, received: {}, ...actual: Array<{}>) {
|
||||
return {
|
||||
message: JSON.stringify(received),
|
||||
pass: false,
|
||||
};
|
||||
}
|
||||
});
|
||||
expect.extend({
|
||||
async foo(this: jest.MatcherUtils, received: {}, ...actual: Array<{}>) {
|
||||
return {
|
||||
@@ -441,6 +449,14 @@ expect.extend({
|
||||
};
|
||||
}
|
||||
});
|
||||
expect.extend({
|
||||
async foo(this: jest.MatcherUtils, received: {}, ...actual: Array<{}>) {
|
||||
return {
|
||||
message: JSON.stringify(received),
|
||||
pass: false
|
||||
};
|
||||
}
|
||||
});
|
||||
expect.extend({
|
||||
foo(this: jest.MatcherUtils) {
|
||||
const isNot: boolean = this.isNot;
|
||||
|
||||
Reference in New Issue
Block a user