|
1 |
| -import { expect as base } from './expect'; |
| 1 | +import { expect as base, type MatcherResult, type MatcherContext } from './expect'; |
2 | 2 | import Ajv from 'ajv';
|
3 | 3 |
|
4 |
| -export const expect = base.extend({ |
| 4 | +export type BaseMatchers = { |
| 5 | + toSimpleEqual(this: MatcherContext<any>, expected: any): MatcherResult; |
| 6 | + toEqual(this: MatcherContext<any>, expected: any): MatcherResult; |
| 7 | + toCaseInsensitiveEqual(this: MatcherContext<any>, expected: string): MatcherResult; |
| 8 | + toBe(this: MatcherContext<any>, expected: any): MatcherResult; |
| 9 | + toBeGreaterThan(this: MatcherContext<any>, expected: number): MatcherResult; |
| 10 | + toBeGreaterThanOrEqual(this: MatcherContext<any>, expected: number): MatcherResult; |
| 11 | + toBeLessThan(this: MatcherContext<any>, expected: number): MatcherResult; |
| 12 | + toBeLessThanOrEqual(this: MatcherContext<any>, expected: number): MatcherResult; |
| 13 | + toBeNaN(this: MatcherContext<any>): MatcherResult; |
| 14 | + toBeNull(this: MatcherContext<any>): MatcherResult; |
| 15 | + toBeUndefined(this: MatcherContext<any>): MatcherResult; |
| 16 | + toBeTruthy(this: MatcherContext<any>): MatcherResult; |
| 17 | + toContain(this: MatcherContext<any>, expected: any): MatcherResult; |
| 18 | + toDeepEqual(this: MatcherContext<any>, expected: any): MatcherResult; |
| 19 | + toStrictEqual(this: MatcherContext<any>, expected: any): MatcherResult; |
| 20 | + toHaveLength(this: MatcherContext<any>, expected: number): MatcherResult; |
| 21 | + toHaveProperty(this: MatcherContext<any>, key: string, value?: any): MatcherResult; |
| 22 | + toMatch(this: MatcherContext<any>, expected: string | RegExp): MatcherResult; |
| 23 | + toThrow(this: MatcherContext<() => any>, expected?: string | RegExp): MatcherResult; |
| 24 | + toSatisfy(this: MatcherContext<any>, expected: (received: any) => boolean): MatcherResult; |
| 25 | + toResolveWith(this: MatcherContext<Promise<any>>, expected: any): Promise<MatcherResult>; |
| 26 | + toRejectWith(this: MatcherContext<Promise<any>>, expected: string): Promise<MatcherResult>; |
| 27 | + toPass(this: MatcherContext<() => any>): Promise<MatcherResult>; |
| 28 | + toMatchSchema(this: MatcherContext<any>, schema: object): MatcherResult; |
| 29 | + toHaveMembers(this: MatcherContext<any[]>, expected: any[]): MatcherResult; |
| 30 | + toIncludeMembers(this: MatcherContext<any[]>, expected: any[]): MatcherResult; |
| 31 | + toHaveType(this: MatcherContext<any>, expected: string): MatcherResult; |
| 32 | +} |
| 33 | + |
| 34 | +export const expect = base.extend<BaseMatchers>({ |
5 | 35 | toSimpleEqual(expected: any) {
|
6 | 36 | const pass = this.received == expected;
|
7 | 37 | const message = this.formatMessage(this.received, expected, 'to equal', this.isNot);
|
|
0 commit comments