UNPKG

jest-expect-openapi

Version:

Jest/Vitest matcher for asserting valid OpenAPI definitions

30 lines (27 loc) 1.19 kB
import { MatcherState } from '@vitest/expect'; declare global { namespace jest { interface Matchers<R> { /** * Assert that a given OpenAPI definition is valid. * * @param transformer If you need to downgrade the given spec to test different usecase you * can pass a transformer function. It takes a single argument, `spec`, that you should * return. */ toBeAValidOpenAPIDefinition(transformer?: (spec: Record<string, unknown>) => Record<string, unknown>): Promise<R>; } } } /** * Assert that a given OpenAPI definition is valid. * * @param definition * @param transformer If you need to transform the given spec to test different usecase you can * pass a transformer function. It takes a single argument, `spec`, that you should return. */ declare function toBeAValidOpenAPIDefinition(this: jest.MatcherUtils | MatcherState, definition: Record<string, unknown>, transformer?: (spec: Record<string, unknown>) => Record<string, unknown>): Promise<{ message: () => string; pass: boolean; }>; export { toBeAValidOpenAPIDefinition as default };