UNPKG

@zerothrow/expect

Version:

Shared test matcher logic for ZeroThrow Result types

23 lines (20 loc) 1.18 kB
import { Result } from '@zerothrow/core'; declare function isResult(value: unknown): value is Result<unknown, Error>; declare function formatError(error: unknown): string; interface MatcherResult { pass: boolean; message: () => string; } interface MatcherContext { equals(a: unknown, b: unknown): boolean; } declare function toBeOkMatcher(received: unknown, _context?: MatcherContext): MatcherResult; declare function toBeOkWithMatcher<T>(received: unknown, expected: T, context: MatcherContext): MatcherResult; declare function toBeErrMatcher(received: unknown, _context?: MatcherContext): MatcherResult; declare function toBeErrWithMatcher<E extends Error>(received: unknown, expected: E | { code?: string; message?: string; }, context: MatcherContext): MatcherResult; declare function toHaveErrorCodeMatcher(received: unknown, code: string): MatcherResult; declare function toHaveErrorMessageMatcher(received: unknown, message: string | RegExp): MatcherResult; export { type MatcherContext, type MatcherResult, formatError, isResult, toBeErrMatcher, toBeErrWithMatcher, toBeOkMatcher, toBeOkWithMatcher, toHaveErrorCodeMatcher, toHaveErrorMessageMatcher };