deno.land / std@0.224.0 / expect / _types.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// deno-lint-ignore-file no-explicit-any
export interface MatcherContext { value: unknown; isNot: boolean; equal: (a: unknown, b: unknown, options?: EqualOptions) => boolean; customTesters: Tester[]; customMessage: string | undefined;}
export type Matcher = ( context: MatcherContext, ...args: any[]) => MatchResult | ExtendMatchResult;
export type Matchers = { [key: string]: Matcher;};export type MatchResult = void | Promise<void> | boolean;export type ExtendMatchResult = { message: () => string; pass: boolean;};export type AnyConstructor = new (...args: any[]) => any;
export type Tester = ( a: any, b: any, customTesters: Tester[],) => void;
// a helper type to match any function. Used so that we only convert functions// to return a promise and not properties.type Fn = (...args: any[]) => unknown;
// converts all the methods in an interface to be async functionsexport type Async<T> = { [K in keyof T]: T[K] extends Fn ? (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>> : T[K];};
export interface Expected { lastCalledWith(...expected: unknown[]): void; lastReturnedWith(expected: unknown): void; nthCalledWith(nth: number, ...expected: unknown[]): void; nthReturnedWith(nth: number, expected: unknown): void; toBeCalled(): void; toBeCalledTimes(expected: number): void; toBeCalledWith(...expected: unknown[]): void; toBeCloseTo(candidate: number, tolerance?: number): void; toBeDefined(): void; toBeFalsy(): void; toBeGreaterThan(expected: number): void; toBeGreaterThanOrEqual(expected: number): void; toBeInstanceOf<T extends AnyConstructor>(expected: T): void; toBeLessThan(expected: number): void; toBeLessThanOrEqual(expected: number): void; toBeNaN(): void; toBeNull(): void; toBeTruthy(): void; toBeUndefined(): void; toBe(expected: unknown): void; toContainEqual(expected: unknown): void; toContain(expected: unknown): void; toEqual(expected: unknown): void; toHaveBeenCalledTimes(expected: number): void; toHaveBeenCalledWith(...expected: unknown[]): void; toHaveBeenCalled(): void; toHaveBeenLastCalledWith(...expected: unknown[]): void; toHaveBeenNthCalledWith(nth: number, ...expected: unknown[]): void; toHaveLength(expected: number): void; toHaveLastReturnedWith(expected: unknown): void; toHaveNthReturnedWith(nth: number, expected: unknown): void; toHaveProperty(propName: string | string[], value?: unknown): void; toHaveReturnedTimes(expected: number): void; toHaveReturnedWith(expected: unknown): void; toHaveReturned(): void; toMatch(expected: RegExp): void; toMatchObject( expected: | Record<PropertyKey, unknown> | Record<PropertyKey, unknown>[], ): void; toReturn(): void; toReturnTimes(expected: number): void; toReturnWith(expected: unknown): void; toStrictEqual(candidate: unknown): void; toThrow<E extends Error = Error>( expected?: string | RegExp | E | (new (...args: any[]) => E), ): void; not: Expected; resolves: Async<Expected>; rejects: Async<Expected>; // This declaration prepares for the `expect.extend` and just only let // compiler pass, the more concrete type definition is defined by user [name: string]: unknown;}
export type MatcherKey = keyof Omit<Expected, "not" | "resolves" | "rejects">;
export type EqualOptions = { customTesters?: Tester[]; msg?: string; formatter?: (value: unknown) => string; strictCheck?: boolean;};
export interface EqualOptionUtil extends MatcherContext { strictCheck?: boolean;}
export interface Colors { comment: { close: string; open: string }; content: { close: string; open: string }; prop: { close: string; open: string }; tag: { close: string; open: string }; value: { close: string; open: string };}type Indent = (arg0: string) => string;type Print = (arg0: unknown) => string;
export type Refs = Array<unknown>;
export type CompareKeys = ((a: string, b: string) => number) | null | undefined;
export interface Config { callToJSON: boolean; compareKeys: CompareKeys; colors: Colors; escapeRegex: boolean; escapeString: boolean; indent: string; maxDepth: number; maxWidth: number; min: boolean; plugins: SnapshotPlugin; printBasicPrototype: boolean; printFunctionName: boolean; spacingInner: string; spacingOuter: string;}
export type Printer = ( val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean,) => string;
interface PluginOptions { edgeSpacing: string; min: boolean; spacing: string;}
type Test = (arg0: any) => boolean;
export interface NewSnapshotPlugin { serialize: ( val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer, ) => string; test: Test;}
export interface OldSnapshotPlugin { print: ( val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors, ) => string; test: Test;}
export type SnapshotPlugin = NewSnapshotPlugin | OldSnapshotPlugin;
export type SnapshotPlugins = Array<SnapshotPlugin>;
Version Info