jest-expect-openapi
v1.0.0
Published
Jest/Vitest matcher for asserting valid OpenAPI definitions
Downloads
2,514
Readme
jest-expect-openapi
A Jest custom matcher for asserting valid OpenAPI definitions. Also supports Vitest.
Installation
npm install jest-expect-openapi --save-dev
Usage
import toBeAValidOpenAPIDefinition from 'jest-expect-openapi';
expect.extend({ toBeAValidOpenAPIDefinition });
test('should be a valid OpenAPI definition', () => {
expect(oas).toBeAValidOpenAPIDefinition();
});
test('should not be a valid OpenAPI definition', () => {
expect(invalidOas).not.toBeAValidOpenAPIDefinition();
});
The usage is nearly identical in Vitest:
import toBeAValidOpenAPIDefinition from 'jest-expect-openapi';
import { expect, test } from 'vitest';
expect.extend({ toBeAValidOpenAPIDefinition });
test('should be a valid OpenAPI definition', () => {
expect(oas).toBeAValidOpenAPIDefinition();
});
test('should not be a valid OpenAPI definition', () => {
expect(invalidOas).not.toBeAValidOpenAPIDefinition();
});