Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/readmeio/jest-expect-openapi
Jest/Vitest matcher for asserting valid OpenAPI definitions
https://github.com/readmeio/jest-expect-openapi
jest oas openapi vitest
Last synced: 6 days ago
JSON representation
Jest/Vitest matcher for asserting valid OpenAPI definitions
- Host: GitHub
- URL: https://github.com/readmeio/jest-expect-openapi
- Owner: readmeio
- License: mit
- Created: 2024-01-19T23:11:18.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-10-01T15:29:34.000Z (about 1 month ago)
- Last Synced: 2024-10-31T10:51:27.954Z (13 days ago)
- Topics: jest, oas, openapi, vitest
- Language: TypeScript
- Homepage:
- Size: 75.2 KB
- Stars: 3
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-expect-openapi
A [Jest](https://jestjs.io/) custom matcher for asserting valid [OpenAPI](https://en.wikipedia.org/wiki/OpenAPI_Specification) definitions. Also supports [Vitest](https://vitest.dev/).
[![npm](https://img.shields.io/npm/v/jest-expect-openapi)](https://npm.im/jest-expect-openapi) [![Build](https://github.com/readmeio/jest-expect-openapi/workflows/CI/badge.svg)](https://github.com/readmeio/jest-expect-openapi)
## Installation
```sh
npm install jest-expect-openapi --save-dev
```## Usage
```js
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:
```js
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();
});
```