An open API service indexing awesome lists of open source software.

https://github.com/readmeio/jest-expect-har

Jest matcher for asserting valid HAR definitions
https://github.com/readmeio/jest-expect-har

har jest vitest

Last synced: 11 months ago
JSON representation

Jest matcher for asserting valid HAR definitions

Awesome Lists containing this project

README

          

> [!IMPORTANT]
> `jest-expect-har` has moved! The source for this library now lives at https://github.com/readmeio/oas.

# jest-expect-har

A [Jest](https://jestjs.io/) custom matcher for asserting valid [HAR]() definitions. Also supports [Vitest](https://vitest.dev/).

[![npm](https://img.shields.io/npm/v/jest-expect-har)](https://npm.im/jest-expect-har) [![Build](https://github.com/readmeio/jest-expect-har/workflows/CI/badge.svg)](https://github.com/readmeio/jest-expect-har)



ReadMe Open Source

## Installation

```sh
npm install jest-expect-har --save-dev
```

## Usage

```js
import toBeAValidHAR from 'jest-expect-har';

expect.extend({ toBeAValidHAR });

test('should be a valid HAR', () => {
expect(har).toBeAValidHAR();
});

test('should not be a valid HAR', () => {
expect(invalidHar).not.toBeAValidHAR();
});
```

The usage is nearly identical in Vitest:

```js
import toBeAValidHAR from 'jest-expect-har';
import { expect, test } from 'vitest';

expect.extend({ toBeAValidHAR });

test('should be a valid HAR', () => {
expect(har).toBeAValidHAR();
});

test('should not be a valid HAR', () => {
expect(invalidHar).not.toBeAValidHAR();
});
```