UNPKG

@zerothrow/vitest

Version:

Vitest matchers for ZeroThrow Result types

52 lines (50 loc) 1.59 kB
declare module 'vitest' { interface Assertion { toBeOk(): void; toBeOkWith<T>(expected: T): void; toBeErr(): void; toBeErrWith<E extends Error>(error: E | { code?: string; message?: string; }): void; toHaveErrorCode(code: string): void; toHaveErrorMessage(message: string | RegExp): void; } } declare function toBeOk(this: any, received: unknown): { pass: boolean; message: () => string; }; declare function toBeOkWith<T>(this: any, received: unknown, expected: T): { pass: boolean; message: () => string; }; declare function toBeErr(this: any, received: unknown): { pass: boolean; message: () => string; }; declare function toBeErrWith<E extends Error>(this: any, received: unknown, expected: E | { code?: string; message?: string; }): { pass: boolean; message: () => string; }; declare function toHaveErrorCode(this: any, received: unknown, code: string): { pass: boolean; message: () => string; }; declare function toHaveErrorMessage(this: any, received: unknown, message: string | RegExp): { pass: boolean; message: () => string; }; declare const vitestMatchers: { toBeOk: typeof toBeOk; toBeOkWith: typeof toBeOkWith; toBeErr: typeof toBeErr; toBeErrWith: typeof toBeErrWith; toHaveErrorCode: typeof toHaveErrorCode; toHaveErrorMessage: typeof toHaveErrorMessage; }; declare function setup(): void; export { setup, toBeErr, toBeErrWith, toBeOk, toBeOkWith, toHaveErrorCode, toHaveErrorMessage, vitestMatchers };