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
- Host: GitHub
- URL: https://github.com/readmeio/jest-expect-har
- Owner: readmeio
- License: mit
- Archived: true
- Created: 2020-07-01T00:16:41.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-03-04T21:31:45.000Z (over 1 year ago)
- Last Synced: 2025-06-10T08:43:24.039Z (about 1 year ago)
- Topics: har, jest, vitest
- Language: TypeScript
- Homepage:
- Size: 1.2 MB
- Stars: 0
- Watchers: 13
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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/).
[](https://npm.im/jest-expect-har) [](https://github.com/readmeio/jest-expect-har)

## 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();
});
```