UNPKG

@plugjs/expect5

Version:

Unit Testing for the PlugJS Build System ========================================

56 lines (55 loc) 2.14 kB
import type { Diff } from './diff'; import type { Expectations } from './expectations'; import type { Matcher } from './matchers'; /** A type identifying any constructor */ export type Constructor<T = any> = new (...args: any[]) => T; /** A type identifying any function */ export type Callable<T = any> = (...args: readonly any[]) => T; /** A simple _record_ indicating an `object` but never an `array` */ export type NonArrayObject<T = any> = { [a: string]: T; [b: symbol]: T; [c: number]: never; }; /** Mappings for our _expanded_ {@link typeOf} implementation */ export type TypeMappings = { bigint: bigint; boolean: boolean; function: Callable; number: number; string: string; symbol: symbol; undefined: undefined; array: readonly any[]; buffer: Buffer; date: Date; map: Map<any, any>; promise: PromiseLike<any>; regexp: RegExp; set: Set<any>; object: NonArrayObject<any>; null: null; }; /** Values returned by our own _expanded_ `{@link typeOf}` */ export type TypeName = keyof TypeMappings; /** Expanded `typeof` implementation returning some extra types */ export declare function typeOf(value: unknown): TypeName; /** Stringify the type of an object (its constructor name) */ export declare function stringifyObjectType(value: object): string; /** Stringify a constructor */ export declare function stringifyConstructor(ctor: Constructor): string; /** Pretty print the value (strings, numbers, booleans) or return the type */ export declare function stringifyValue(value: unknown): string; /** Add the `a`/`an`/... prefix to the type name */ export declare function prefixType(type: TypeName): string; export declare const matcherMarker: unique symbol; export declare function isMatcher(what: any): what is Matcher; export declare class ExpectationError extends Error { remarks?: string; diff?: Diff | undefined; /** * Create an {@link ExpectationError} from a {@link Expectations} instance * and details message, including an optional {@link Diff} */ constructor(expectations: Expectations, details: string, diff?: Diff); }