# jest-expect-har

> Jest/Vitest matcher for asserting valid HAR definitions

Latest version **12.0.0** (published 2026-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install jest-expect-har
pnpm add jest-expect-har
yarn add jest-expect-har
bun add jest-expect-har
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 12.0.0 |
| Published | 2026-11-19 |
| First published | 2020-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 3 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 401 |
| Author | Jon Ursenbach |
| Maintainers | gkoberger, domharrington, mjcuva, jonursenbach, rafegoldberg, darrenyong |
| Keywords | jest, vitest, har, matchers, expect, extend, extended, test, testing, assertions |

## Links

- npm: https://www.npmjs.com/package/jest-expect-har
- Repository: https://github.com/readmeio/oas
- Homepage: https://github.com/readmeio/oas#readme
- Issues: https://github.com/readmeio/oas/issues
- npm.io page: https://npm.io/package/jest-expect-har

## Dependencies (3)

- [har-validator](https://npm.io/package/har-validator.md) ^5.1.5
- [@vitest/expect](https://npm.io/package/@vitest/expect.md) ^5.0.5
- [@types/har-format](https://npm.io/package/@types/har-format.md) ^1.2.14

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 12.0.0 (latest) — 2026-11-19
- 11.0.0 — 2026-09-04
- 10.1.2 — 2026-09-02
- 10.1.1 — 2026-08-04
- 10.1.0 — 2026-07-16
- 10.0.3 — 2026-06-04
- 10.0.2 — 2026-05-07
- 10.0.1 — 2026-04-02
- 10.0.0 — 2026-03-02
- 9.0.0 — 2025-12-16
- 8.0.8 — 2025-11-11
- 8.0.7 — 2025-10-06
- 8.0.6 — 2025-08-04
- 8.0.5 — 2025-07-29
- 8.0.4 — 2025-06-04
- … 22 more at https://npm.io/package/jest-expect-har/versions

## README

# jest-expect-har

A [Vitest](https://vitest.dev/) and [Jest](https://jestjs.io/) custom matcher for asserting valid [HAR](<https://en.wikipedia.org/wiki/HAR_(file_format)>) definitions.

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

<a href="https://readme.com">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/readmeio/.github/main/oss-header-dark.png">
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/readmeio/.github/main/oss-header.png">
  <img alt="ReadMe Open Source" src="https://raw.githubusercontent.com/readmeio/.github/main/oss-header.png">
</picture>
</a>

## Installation

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

## Usage

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

The usage is nearly identical in Jest:

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

If your project uses [`@jest/globals`](https://jestjs.io/docs/api#jestglobals) instead of Jest's injected globals, `toBeAValidHAR` is typed there too:

```ts
import { expect, test } from '@jest/globals';
import toBeAValidHAR from 'jest-expect-har';

expect.extend({ toBeAValidHAR });

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

---
_Source: https://npm.io/package/jest-expect-har · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
