import { use } from 'chai'; import { stringify, Constructable } from '@vitest/utils'; export { setupColors } from '@vitest/utils'; import { diff } from '@vitest/utils/diff'; export { DiffOptions } from '@vitest/utils/diff'; type Formatter = (input: string | number | null | undefined) => string; declare function getMatcherUtils(): { EXPECTED_COLOR: { (input: unknown): string; open: string; close: string; }; RECEIVED_COLOR: { (input: unknown): string; open: string; close: string; }; INVERTED_COLOR: { (input: unknown): string; open: string; close: string; }; BOLD_WEIGHT: { (input: unknown): string; open: string; close: string; }; DIM_COLOR: { (input: unknown): string; open: string; close: string; }; matcherHint: (matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions) => string; printReceived: (object: unknown) => string; printExpected: (value: unknown) => string; }; type FirstFunctionArgument = T extends (arg: infer A) => unknown ? A : never; type ChaiPlugin = FirstFunctionArgument; type Tester = (a: any, b: any) => boolean | undefined; interface MatcherHintOptions { comment?: string; expectedColor?: Formatter; isDirectExpectCall?: boolean; isNot?: boolean; promise?: string; receivedColor?: Formatter; secondArgument?: string; secondArgumentColor?: Formatter; } interface MatcherState { assertionCalls: number; currentTestName?: string; dontThrow?: () => void; error?: Error; equals: (a: unknown, b: unknown, customTesters?: Array, strictCheck?: boolean) => boolean; expand?: boolean; expectedAssertionsNumber?: number | null; expectedAssertionsNumberErrorGen?: (() => Error) | null; isExpectingAssertions?: boolean; isExpectingAssertionsError?: Error | null; isNot: boolean; promise: string; suppressedErrors: Array; testPath?: string; utils: ReturnType & { diff: typeof diff; stringify: typeof stringify; iterableEquality: Tester; subsetEquality: Tester; }; soft?: boolean; } interface SyncExpectationResult { pass: boolean; message: () => string; actual?: any; expected?: any; } type AsyncExpectationResult = Promise; type ExpectationResult = SyncExpectationResult | AsyncExpectationResult; interface RawMatcherFn { (this: T, received: any, expected: any, options?: any): ExpectationResult; } type MatchersObject = Record>; interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining { (actual: T, message?: string): Assertion; unreachable(message?: string): never; soft(actual: T, message?: string): Assertion; extend(expects: MatchersObject): void; assertions(expected: number): void; hasAssertions(): void; anything(): any; any(constructor: unknown): any; getState(): MatcherState; setState(state: Partial): void; not: AsymmetricMatchersContaining; } interface AsymmetricMatchersContaining { stringContaining(expected: string): any; objectContaining(expected: T): any; arrayContaining(expected: Array): any; stringMatching(expected: string | RegExp): any; } interface JestAssertion extends jest.Matchers { toEqual(expected: E): void; toStrictEqual(expected: E): void; toBe(expected: E): void; toMatch(expected: string | RegExp): void; toMatchObject(expected: E): void; toContain(item: E): void; toContainEqual(item: E): void; toBeTruthy(): void; toBeFalsy(): void; toBeGreaterThan(num: number | bigint): void; toBeGreaterThanOrEqual(num: number | bigint): void; toBeLessThan(num: number | bigint): void; toBeLessThanOrEqual(num: number | bigint): void; toBeNaN(): void; toBeUndefined(): void; toBeNull(): void; toBeDefined(): void; toBeInstanceOf(expected: E): void; toBeCalledTimes(times: number): void; toHaveLength(length: number): void; toHaveProperty(property: string | (string | number)[], value?: E): void; toBeCloseTo(number: number, numDigits?: number): void; toHaveBeenCalledTimes(times: number): void; toHaveBeenCalled(): void; toBeCalled(): void; toHaveBeenCalledWith(...args: E): void; toBeCalledWith(...args: E): void; toHaveBeenNthCalledWith(n: number, ...args: E): void; nthCalledWith(nthCall: number, ...args: E): void; toHaveBeenLastCalledWith(...args: E): void; lastCalledWith(...args: E): void; toThrow(expected?: string | Constructable | RegExp | Error): void; toThrowError(expected?: string | Constructable | RegExp | Error): void; toReturn(): void; toHaveReturned(): void; toReturnTimes(times: number): void; toHaveReturnedTimes(times: number): void; toReturnWith(value: E): void; toHaveReturnedWith(value: E): void; toHaveLastReturnedWith(value: E): void; lastReturnedWith(value: E): void; toHaveNthReturnedWith(nthCall: number, value: E): void; nthReturnedWith(nthCall: number, value: E): void; } type VitestAssertion = { [K in keyof A]: A[K] extends Chai.Assertion ? Assertion : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion; } & ((type: string, message?: string) => Assertion); type Promisify = { [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify : (...args: A) => Promise : O[K]; }; interface Assertion extends VitestAssertion, JestAssertion { toBeTypeOf(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined'): void; toHaveBeenCalledOnce(): void; toSatisfy(matcher: (value: E) => boolean, message?: string): void; resolves: Promisify>; rejects: Promisify>; } declare global { namespace jest { interface Matchers { } } } interface AsymmetricMatcherInterface { asymmetricMatch(other: unknown): boolean; toString(): string; getExpectedType?(): string; toAsymmetricMatcher?(): string; } declare abstract class AsymmetricMatcher implements AsymmetricMatcherInterface { protected sample: T; protected inverse: boolean; $$typeof: symbol; constructor(sample: T, inverse?: boolean); protected getMatcherContext(expect?: Chai.ExpectStatic): State; abstract asymmetricMatch(other: unknown): boolean; abstract toString(): string; getExpectedType?(): string; toAsymmetricMatcher?(): string; } declare class StringContaining extends AsymmetricMatcher { constructor(sample: string, inverse?: boolean); asymmetricMatch(other: string): boolean; toString(): string; getExpectedType(): string; } declare class Anything extends AsymmetricMatcher { asymmetricMatch(other: unknown): boolean; toString(): string; toAsymmetricMatcher(): string; } declare class ObjectContaining extends AsymmetricMatcher> { constructor(sample: Record, inverse?: boolean); getPrototype(obj: object): any; hasProperty(obj: object | null, property: string): boolean; asymmetricMatch(other: any): boolean; toString(): string; getExpectedType(): string; } declare class ArrayContaining extends AsymmetricMatcher> { constructor(sample: Array, inverse?: boolean); asymmetricMatch(other: Array): boolean; toString(): string; getExpectedType(): string; } declare class Any extends AsymmetricMatcher { constructor(sample: unknown); fnNameFor(func: Function): string; asymmetricMatch(other: unknown): boolean; toString(): string; getExpectedType(): string; toAsymmetricMatcher(): string; } declare class StringMatching extends AsymmetricMatcher { constructor(sample: string | RegExp, inverse?: boolean); asymmetricMatch(other: string): boolean; toString(): string; getExpectedType(): string; } declare const JestAsymmetricMatchers: ChaiPlugin; declare function equals(a: unknown, b: unknown, customTesters?: Array, strictCheck?: boolean): boolean; declare function isAsymmetric(obj: any): boolean; declare function hasAsymmetric(obj: any, seen?: Set): boolean; declare function isA(typeName: string, value: unknown): boolean; declare function fnNameFor(func: Function): string; declare function hasProperty(obj: object | null, property: string): boolean; declare function isImmutableUnorderedKeyed(maybeKeyed: any): boolean; declare function isImmutableUnorderedSet(maybeSet: any): boolean; declare function iterableEquality(a: any, b: any, aStack?: Array, bStack?: Array): boolean | undefined; declare function subsetEquality(object: unknown, subset: unknown): boolean | undefined; declare function typeEquality(a: any, b: any): boolean | undefined; declare function arrayBufferEquality(a: unknown, b: unknown): boolean | undefined; declare function sparseArrayEquality(a: unknown, b: unknown): boolean | undefined; declare function generateToBeMessage(deepEqualityName: string, expected?: string, actual?: string): string; declare const MATCHERS_OBJECT: unique symbol; declare const JEST_MATCHERS_OBJECT: unique symbol; declare const GLOBAL_EXPECT: unique symbol; declare function getState(expect: ExpectStatic): State; declare function setState(state: Partial, expect: ExpectStatic): void; declare const JestChaiExpect: ChaiPlugin; declare const JestExtend: ChaiPlugin; export { Any, Anything, ArrayContaining, Assertion, AsymmetricMatcher, AsymmetricMatcherInterface, AsymmetricMatchersContaining, AsyncExpectationResult, ChaiPlugin, ExpectStatic, ExpectationResult, FirstFunctionArgument, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAssertion, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, MatcherHintOptions, MatcherState, MatchersObject, ObjectContaining, RawMatcherFn, StringContaining, StringMatching, SyncExpectationResult, Tester, arrayBufferEquality, equals, fnNameFor, generateToBeMessage, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, iterableEquality, setState, sparseArrayEquality, subsetEquality, typeEquality };