> ## Documentation Index
> Fetch the complete documentation index at: https://e2e.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# expect

> API reference for expect in e2e, with retrying locator assertions, screenshot comparison, plain value matchers, expect.poll, and expect.soft.

`expect(locator)` waits for an app condition, `expect(screen)` compares the
screen against a stored screenshot, and `expect(value)` checks a value
immediately. `expect.poll` re-reads a value until its matcher passes,
`expect.soft` keeps a failure for the end of the test body instead of
throwing it, and `expect.any` and the other
[asymmetric matchers](#asymmetric-matchers) stand in for values inside a
structural comparison.

```ts title="tests/checkout.e2e.ts"

test('checkout summary', async ({ screen }) => {
  await expect(screen.getByRole('heading', 'Checkout')).toBeVisible();
  await expect(screen.getByTestId('line-item')).toHaveCount(2);
  const total = await screen.getByTestId('total').textContent();
  expect(total).toContain('$');
});
```

## Reference

| Call | Returns |
| --- | --- |
| [`expect(locator, message?)`](#locator-matchers) | `AsyncExpectation` |
| [`expect(screen, message?)`](#screenshot-matchers) | `ScreenExpectation` |
| [`expect(fixture)`](#browser-matchers) | The engine's matcher set |
| [`expect(value, message?)`](#value-matchers) | `ValueExpectation<T>` |
| [`expect.poll(read, options?)`](#polling-a-value) | `PollExpectation<T>` |
| [`expect(fn).toPass(options?)`](#retrying-a-block) | `Promise<void>` |
| [`expect.soft(actual, message?)`](#soft-assertions) | The same matchers, failures kept |
| [`expect.any(Class)` and others](#asymmetric-matchers) | `AsymmetricMatcher` |

`expect` tells the argument apart by what it is:

- A built-in fixture an engine contributes can provide matchers, such as
  `expect(browser).toHaveURL()`. Its engine attaches them through
  [`expectable`](https://e2e.com/docs/reference/engine#contributed-fixtures).
- Every other argument gets the value matchers, a promise included. Await a
  promise before passing its result to `expect`.

The declarations are under [Types](#types).

### Locator matchers

`expect(locator)` returns an `AsyncExpectation`. Each matcher polls until it
holds or its timeout passes, under the rules in [Behavior](#behavior):
[Strictness](#strictness), [Text matching](#text-matching), and
[Secure fields](#secure-fields) among them. The options are in
[`AsyncExpectation`](#asyncexpectation-and-textmatcheroptions).

A second argument describes the check, in `expect(locator, message)` and
`expect.soft(locator, message)`. It opens each assertion failure of the
matchers below, `.not` included, before the matcher and the locator, and the
`LOCATOR_AMBIGUOUS` error of a locator that matches more than one node. An
invalid option or a denied read fails without it. `expect(screen, message)`
takes one the same way.

```ts
await expect(screen.getByTestId('cart-empty'), 'the cart is empty').toBeVisible();
// ASSERTION_FAILED: the cart is empty: expect.toBeVisible failed
// locator: getByTestId("cart-empty")
```

| Matcher | Description |
| --- | --- |
| [`toBeVisible`](#tobevisible-and-tobehidden) | Waits for visibility |
| [`toBeHidden`](#tobevisible-and-tobehidden) | Waits for hidden or absent state |
| [`toBeInViewport`](#tobeinviewport) | Waits for the match to be in view |
| [`toBeAttached`](#tobeattached) | Waits for one match to exist |
| [`toBeEnabled`](#tobeenabled-and-tobedisabled) | Waits for enabled state |
| [`toBeDisabled`](#tobeenabled-and-tobedisabled) | Waits for disabled state |
| [`toBeEditable`](#tobeeditable) | Waits for an enabled control that is not read-only |
| [`toBeChecked`](#tobechecked-tobeselected-and-tobeexpanded) | Waits for checked state |
| [`toBeSelected`](#tobechecked-tobeselected-and-tobeexpanded) | Waits for selected state |
| [`toBeExpanded`](#tobechecked-tobeselected-and-tobeexpanded) | Waits for expanded state |
| [`toBeFocused`](#tobefocused) | Waits for focused state |
| [`toBeEmpty`](#tobeempty) | Waits for an empty field or a node with no text |
| [`toHaveText`](#tohavetext-and-tocontaintext) | Waits for exact normalized text |
| [`toContainText`](#tohavetext-and-tocontaintext) | Waits for contained normalized text |
| [`toHaveValue`](#tohavevalue) | Waits for a control's value |
| [`toHaveAttribute`](#tohaveattribute) | Waits for an attribute |
| [`toHaveCount`](#tohavecount) | Waits for an exact match count |
| [`toHaveAccessibleName`](#tohaveaccessiblename) | Waits for an accessible name |
| [`toHaveRole`](#tohaverole) | Waits for a role |
| [`toHaveScreenshot`](#screenshot-matchers) | Compares with a stored screenshot |

#### `toBeVisible` and `toBeHidden`

`toBeVisible` waits for the one match to be shown. `toBeHidden` waits for a
hidden or absent state. On a device, a node whose centre the soft keyboard
covers is hidden; [Visibility](https://e2e.com/docs/reference/mobile#visibility) lists the
exceptions.

```ts
await expect(screen.getByRole('dialog')).toBeVisible();
await expect(screen.getByRole('dialog')).not.toBeVisible({ timeout: 10_000 });
await expect(screen.getByRole('dialog')).toBeVisible({ visible: false }); // as toBeHidden()
```

#### `toBeInViewport`

Waits for part of the one match to be inside the viewport. It never scrolls,
and it says nothing about another element covering the match. No match counts
as outside the viewport, so `.not` accepts zero matches. A zero-size box, or a
web element with no box such as `display: none`, also counts as outside.

```ts
await expect(screen.getByRole('toolbar', 'Selection')).toBeInViewport();
await expect(screen.getByRole('toolbar', 'Selection')).toBeInViewport({ ratio: 0.5 });
await expect(screen.getByRole('alert')).not.toBeInViewport();
```

`ratio` is a number from `0` to `1` setting the share of the box that must be
inside. `0` means any positive area, the same as omitting `ratio`. Any value
outside `0` to `1` fails with `INVALID_ARGUMENT`. What counts as inside depends
on the engine:

| Engine | Measures | `ratio` |
| --- | --- | --- |
| `@e2e-dev/web` | The viewport, scrolling or `overflow` ancestors, and frames clip the box, as in Playwright | Supported |
| `@e2e-dev/mobile` | Scroll containers clip the device-reported bounds, and offscreen nodes leave the tree | `ratio > 0` fails with `UNSUPPORTED_CAPABILITY` once the node is on screen |

It fails at once with `UNSUPPORTED_CAPABILITY`, `.not` included, if the target's
engine does not implement
[`viewportIntersection`](https://e2e.com/docs/reference/engine#viewport-intersection), or if the
engine cannot report a node's bounds or screen position.

#### `toBeAttached`

Waits for one match to exist, hidden or shown, where `toBeVisible` needs a
shown one.

```ts
await expect(screen.getByText('Loaded')).toBeAttached();
await expect(screen.getByText('Loading')).toBeAttached({ attached: false });
```

Negated, or with `attached: false`, it waits for no match and passes once
nothing matches.

#### `toBeEnabled` and `toBeDisabled`

`toBeEnabled` waits for an enabled node; `toBeDisabled` waits for a disabled
one.

```ts
await expect(screen.getByRole('button', 'Pay')).toBeEnabled();
await expect(screen.getByRole('button', 'Pay')).toBeEnabled({ enabled: false }); // as toBeDisabled()
```

A node is enabled unless it reports `disabled`. On the web, `disabled` is
the state the browser applies, not the attribute alone, as in Playwright:

- A control inside a `<fieldset disabled>` is disabled unless it sits in
  that fieldset's first `<legend>`.
- `aria-disabled="true"` on an ancestor disables the widgets below it until
  an `aria-disabled="false"` cuts the chain.

#### `toBeEditable`

Waits for an enabled control that is not read-only.

```ts
await expect(screen.getByLabel('Email')).toBeEditable();
await expect(screen.getByLabel('Order id')).toBeEditable({ editable: false }); // read-only or disabled
```

- On the web, read-only follows Playwright's rules: an `input`, `textarea`,
  or `select` reads its `readonly` attribute, with any value, and an element
  of a role that takes `aria-readonly` (`textbox`, `combobox`, `gridcell`,
  and the rest) reads `aria-readonly="true"`, in any case. An editing host
  without such a role, such as a plain `<div contenteditable>`, and any
  element inside one, is never read-only.
- A disabled node is not editable either, as
  [`toBeEnabled`](#tobeenabled-and-tobedisabled) reads it.
- Any other node, such as a button, has no read-only state. It fails the
  matcher, negated too, and the failure message says so.
- On a device, a text field has a read-only state only where the platform
  reports whether it takes text, as Android does. iOS does not, so an iOS
  field fails the matcher rather than pass as a guess.
- On a Mac, a text field is read-only when macOS reports its value cannot be
  set. A combo box is editable when it takes text; a pop-up menu, which takes
  none, has no read-only state.
- The engines report this state from the `@e2e-dev/web`,
  `@e2e-dev/mobile`, and `@e2e-dev/desktop` releases that need `e2e`
  0.25.0. With an older engine, every node fails with
  `no read-only state`: update the engine with `e2e`.

#### `toBeChecked`, `toBeSelected`, and `toBeExpanded`

Each waits for its state: checked, selected, or expanded.

```ts
await expect(screen.getByLabel('Subscribe')).toBeChecked({ checked: false });
await expect(screen.getByRole('tab', 'Billing')).toBeSelected();
```

A missing `checked`, `selected`, or `expanded` state counts as `false`, so
`.not.toBeChecked()` passes on a button or a heading.

#### `toBeFocused`

Waits for focused state.

```ts
await expect(screen.getByLabel('Email')).toBeFocused();
```

#### `toBeEmpty`

Waits for the one match to be empty.

```ts
await expect(screen.getByLabel('Search')).toBeEmpty();
await expect(screen.getByTestId('cart')).not.toBeEmpty();
```

- Empty is the state the engine reports. The web engine follows Playwright:
  an `input` or `textarea` is empty when its value is `''`, read as it is, so
  a space is not empty. Any other element is empty when its text content,
  trimmed, is `''`. Hidden text counts, unlike
  [`toHaveText`](#tohavetext-and-tocontaintext), so a `select` with options
  is never empty, and neither is a `<div>` whose only text is hidden.
- The mobile engine reads a text field by its value, so a label or hint is
  not content, and any other node by the text and values in its subtree. iOS
  reports a field Flutter or Compose Multiplatform draws as a plain view, so
  its placeholder counts and an empty one is not empty.
- The desktop engine reports no empty state yet. There, and on an engine
  release from before this matcher, it fails either way, and the failure
  message says so.

#### `toHaveText` and `toContainText`

`toHaveText` waits for exact normalized text; `toContainText` waits for
contained normalized text. Both take a single `TextMatch` or a list.

```ts
await expect(screen.getByRole('status')).toHaveText('Saved');
await expect(screen.getByRole('alert')).not.toContainText('error', { ignoreCase: true });
await expect(screen.getByTestId('todo')).toHaveText(['Write spec', /^Ship/, 'Release']);
await expect(screen.getByTestId('todo')).toContainText(['spec', 'Release']);
```

A list form's failure message lists every text observed.

| Form | Holds when |
| --- | --- |
| `toHaveText([...])` | The match count equals the list length, and the match at each position satisfies the entry there: a string exactly after normalization, a `RegExp` by test. An empty list holds when nothing matches |
| `toContainText([...])` | Each entry is contained by a distinct match, in list order, as Playwright's does. Extra matches before, between, or after are fine, a repeated entry needs a match of its own, and an empty list always holds |

<Note>
Negated, `toContainText([...])` fails as soon as that ordered subsequence
exists, so `not.toContainText(['Deleted'])` fails while any match contains
`Deleted`.
</Note>

#### `toHaveValue`

Waits for a control's value, compared as it is.

```ts
await expect(screen.getByLabel('Email')).toHaveValue('ada@example.test');
await expect(screen.getByLabel('Search')).toHaveValue('');
```

- No normalization: newlines and trailing spaces count, and the failure
  message prints the value that way.
- A `contenteditable` editor's value is its rendered text, kept the same way.
  An empty editor reads as `''`.
- A control the platform reports without a value, such as a cleared field on
  a device, reads as `''`.
- On the web, a `slider`, `spinbutton`, `progressbar`, `meter`, or `scrollbar`
  that is not a native form control or an editor reads its `aria-valuetext`,
  otherwise its `aria-valuenow`, skipping a blank one. Without either, a native
  `<progress>` or `<meter>` with a `value` attribute reads the browser's
  built-in `.value`, clamped to its range. A `slider` or `spinbutton`
  with none reads as `''`, and any other widget with none, such as an
  indeterminate `<progress>`, has no value and is refused.
- On a device, a node reads the accessibility value the platform reports.
  Android drops the value of a non-editable node when it repeats the node's
  label.
- Any other node with no value, such as a heading or a link, never satisfies
  `toHaveValue`, negated or not. The message reads
  `no value (not a form control)`.

#### `toHaveAttribute`

Waits for the attribute to be present; with `value`, for it to match.

```ts
await expect(screen.getByRole('link', 'Help')).toHaveAttribute('target');
await expect(screen.getByRole('link', 'Help')).toHaveAttribute('href', '/help');
```

#### `toHaveCount`

Waits for an exact match count.

```ts
await expect(screen.getByTestId('todo')).toHaveCount(3);
```

#### `toHaveAccessibleName`

Waits for an accessible name.

```ts
await expect(screen.getByRole('button', { name: /close/i })).toHaveAccessibleName('Close');
```

#### `toHaveRole`

Waits for the one match to have the role, compared as a string.

```ts
await expect(screen.getByTestId('save')).toHaveRole('button');
await expect(screen.getByTestId('wifi')).not.toHaveRole('checkbox');
```

- `role` takes the vocabulary [`getByRole`](https://e2e.com/docs/reference/screen#getbyrole)
  takes. Its alias `img` reads as `image`. From JavaScript, any other string
  is compared as written, and an empty one is `INVALID_ARGUMENT`.
- It compares the role [`screen.tree()`](https://e2e.com/docs/reference/screen#screen-tree)
  shows, so the role hierarchy does not count: a `switch` is not a
  `checkbox`.
- On the web, an editing host (`contenteditable`) reads as `textbox`
  whatever its tag, though `getByRole` finds it by its tag's role.
- A node the tree shows without a role, such as a `<div>` of text, fails it,
  and the failure message reads `no role`.

### Screenshot matchers

`expect(screen)` and `expect(locator)` compare against a PNG stored beside
the test file, on every engine that captures pixels. The
[Visual comparison](https://e2e.com/docs/visual-testing) guide shows the workflow.

| Matcher | Description |
| --- | --- |
| [`expect(screen).toHaveScreenshot`](#tohavescreenshot) | Compares the whole screen |
| [`expect(locator).toHaveScreenshot`](#tohavescreenshot) | Compares a locator's one match |

#### `toHaveScreenshot`

Waits for the screen, or the one match of a locator, to look like its stored
screenshot: `name`, or one named after the test.

```ts
await expect(screen).toHaveScreenshot('home.png');
await expect(screen.getByRole('navigation')).toHaveScreenshot();
await expect(screen).toHaveScreenshot('feed.png', { mask: [screen.getByTestId('timestamp')], maxDiffPixels: 50 });
```

Both forms take the [Screenshot options](#screenshot-options).

| Property | Value |
| --- | --- |
| Stored at | `<test file>-snapshots/<name>-<target>-<os>.png`; `.png` is added to a name without it |
| Unnamed | The test's title path, lowercase, and a count: `checkout-pays-by-card-1` |
| Missing | Taken from two screenshots in a row that are the same within the tolerance, then `ASSERTION_FAILED`. Written beside the test; in CI without `--update-snapshots` only attached to the results, at `snapshots/<path in the project>` |
| Written earlier in the run | Without `--update-snapshots`, and always for `.not`, no comparison passes against a screenshot the same run wrote (a retry, a repeat, another test naming it): `ASSERTION_FAILED` until the next run. With `--update-snapshots` a positive matcher compares and may write it again |
| Different | Retried until one matches or the timeout; then `ASSERTION_FAILED` with `-expected`, `-actual`, and `-diff` images on the step |
| `--update-snapshots`, `-u` | A missing or different stored screenshot is written from a screen that holds still, and the matcher passes |
| `.not` | Passes once the screen differs; with nothing stored it is `ASSERTION_FAILED` |
| Tolerance | Both `maxDiffPixels` and `maxDiffPixelRatio` set: the smaller wins |

| Throws | When |
| --- | --- |
| `INVALID_ARGUMENT` | Before the screen is read: a name with a path separator, an option the matcher does not take (Playwright's `fullPage`, `animations`, `clip`), a value out of range, or `expect` on a screen scoped to a frame. Compare a locator inside the frame instead |
| `ASSERTION_FAILED` | A missing, different, or same-run stored screenshot, as in the table above |
| `POLICY_DENIED` | The engine can't prove every secure field on screen is masked |

#### Screenshot options

| Option | Type | Default |
| --- | --- | --- |
| `threshold` | `number` | `0.2` |
| `maxDiffPixels` | `number` | `0` |
| `maxDiffPixelRatio` | `number` | `0` |
| `mask` | `readonly Locator[]` | - |
| `maskColor` | `string` | `#ff00ff` |
| `timeout` | `number` | `config.assertionTimeout` |

- `threshold` is how far one pixel's color may drift and still count as the
  same, from 0 (exact) to 1.
- `maxDiffPixels` is how many pixels may differ.
- `maxDiffPixelRatio` is the share of the pixels that may differ, from 0 to 1.
- `mask` lists locators painted over before comparing, for content that
  changes from run to run.
- `maskColor` is the color of the `mask` boxes, as `#rrggbb`.
- `timeout` is the assertion budget in milliseconds.

The type is [`ScreenshotOptions`](#screenexpectation-and-screenshotoptions).

### browser matchers

Contributed by `@e2e-dev/web`; the `BrowserExpectation` type is exported
from that package. Every matcher call is a recorded `expect.<matcher>`
assertion step.

| Matcher | Description |
| --- | --- |
| [`toHaveURL`](#tohaveurl) | Waits for the current URL |
| [`toHaveTitle`](#tohavetitle) | Waits for the current title |
| [`toHaveClass`](#tohaveclass) | Waits for a target's `class` |

Any other option key is `INVALID_ARGUMENT`, such as `ignoreCase` on
`toHaveTitle`, which Playwright does not take either.

#### `toHaveURL`

Waits for the current URL to match.

```ts
await expect(browser).toHaveURL('/dashboard');
await expect(browser).toHaveURL(/\/orders\/\d+$/);
```

- A relative string resolves against the base URL and matches exactly after
  normalization. As in Playwright, `*` and `{` are literal here; a glob is for
  [`browser.waitForURL`](https://e2e.com/docs/reference/web#waitforurl).
- A `RegExp` tests the full URL.
- Anything else, such as a predicate function, is `INVALID_ARGUMENT`.
- It takes Playwright's `ignoreCase`, as the locator matchers do
  ([Text matching](#text-matching)).

#### `toHaveTitle`

Waits for the current title to match.

```ts
await expect(browser).toHaveTitle(/Dashboard/);
```

#### `toHaveClass`

Waits for the target's `class` attribute to match: a string is the whole
normalized class list, a `RegExp` is tested against it.

```ts
await expect(browser).toHaveClass(browser.locator('.card'), 'card active');
```

- It polls for the node too: a target that matches nothing yet is one more
  poll, not a failure, until the assertion timeout runs out.
- An ambiguous target still fails at once with `LOCATOR_AMBIGUOUS`.
- It reads the `class` attribute, so `''` matches `class=""` and not an
  element with no `class` attribute at all. Playwright's `toHaveClass('')`
  accepts both.

### Value matchers

`expect(value)` runs synchronously without retrying. For a value that may
still change, use [Polling a value](#polling-a-value).

| Matcher | Description |
| --- | --- |
| [`toBe`](#tobe) | Compares with `Object.is` |
| [`toEqual`](#toequal) | Recursive structural equality |
| [`toMatchObject`](#tomatchobject) | Recursive subset match |
| [`toBeTruthy`, `toBeFalsy`](#tobetruthy-and-tobefalsy) | Truthy or falsy value |
| [`toBeNull`, `toBeUndefined`, `toBeDefined`](#tobenull-tobeundefined-and-tobedefined) | `null`, `undefined`, or defined |
| [`toHaveLength`](#tohavelength) | `length` equals `expected` |
| [`toHaveProperty`](#tohaveproperty) | Property at a path |
| [`toContain`](#tocontain) | String or collection containment |
| [`toMatch`](#tomatch) | String or `RegExp` match |
| [`toBeGreaterThan` and others](#numeric-comparisons) | Numeric bound holds |
| [`toBeCloseTo`](#tobecloseto) | Within `10 ** -digits / 2` |
| [`toMatchSchema`](#matching-a-schema) | Standard Schema validation |
| [`toBeOK`](#tobeok) | Response status is 2xx |

A matcher that cannot evaluate its value fails as `ASSERTION_FAILED`, like a
mismatch. Examples are `toContain` on a number, or `toHaveLength` on a value
without a numeric `length`. So under `expect.poll`, a value that has not
taken its final shape yet is one more failing sample.

#### `toBe`

Compares with `Object.is`.

```ts
expect(status).toBe('paid');
```

#### `toEqual`

Performs recursive structural equality the way Jest's does.

```ts
expect(payload).toEqual({ ok: true, items: [{ sku: 'a' }] });
```

- Primitives compare with `Object.is`, so `NaN` equals `NaN` and `0` does not
  equal `-0`.
- Arrays and plain objects compare by their contents, `Date` by time,
  `RegExp` by source and flags, `Map` and `Set` by their entries.
- A property whose value is `undefined` is treated as absent, and a sparse
  array equals one holding `undefined`.
- Class types are not compared: a class instance equals a plain object with
  the same properties. There is no `toStrictEqual`; see
  [Not included](#not-included).

#### `toMatchObject`

Requires every property of `expected` to match recursively.
The matcher returns `void`. Keep the original value if you need to read
properties after the check.

```ts
expect(order).toMatchObject({ customer: { name: 'Ada' }, lines: [{ sku: 'a' }, { sku: 'b' }] });
```

- Properties `expected` does not name are ignored.
- An array in `expected` matches an array of the same length, element by
  element, each element again as a subset.
- Both sides must be objects; a primitive on either side is refused.

#### `toBeTruthy` and `toBeFalsy`

Require a truthy or a falsy value.

```ts
expect(created).toBeTruthy();
```

#### `toBeNull`, `toBeUndefined`, and `toBeDefined`

`toBeNull` requires `null` and `toBeUndefined` requires `undefined`.
`toBeDefined` requires any value but `undefined`; `null` passes.

```ts
expect(row).toBeDefined();
```

#### `toHaveLength`

Requires a `length` property equal to `expected`: a string, an array, or
anything array-like.

```ts
expect(items).toHaveLength(3);
```

#### `toHaveProperty`

Requires the property at `path` to exist; with `expected`, to equal it by
`toEqual` rules.

```ts
expect(order).toHaveProperty('customer.email', 'ada@example.test');
expect(order).toHaveProperty(['lines', 0, 'sku'], 'a');
```

- `path` is dotted (`'user.address.city'`) or an array of keys
  (`['user', 'address', 'city']`). Use the array form when a key contains a
  dot, or to index an array by number.
- Inherited properties count, and a property holding `undefined` exists.
- A string, number, or boolean on the path is read through its wrapper
  object, as in Jest, so `toHaveProperty('label.length', 3)` and
  `toHaveProperty(['label', 0], 'a')` reach into a string.
- `null` and `undefined` have no properties.

#### `toContain`

Requires string or collection containment.

```ts
expect(total).toContain('$');
expect(rows).toContain(expect.objectContaining({ status: 'paid' }));
```

- On a string, `expected` must be a string, and it is a substring check. An
  asymmetric matcher is refused there:
  `expect('abc').toContain(expect.stringContaining('a'))` fails.
- On a collection, an element must equal `expected`. This form takes
  [asymmetric matchers](#asymmetric-matchers).

#### `toMatch`

Requires a string or `RegExp` match.

```ts
expect(id).toMatch(/^usr_/);
```

A pattern that is neither a string nor a `RegExp` is `INVALID_ARGUMENT`.

#### Numeric comparisons

`toBeGreaterThan` and `toBeLessThan` require a numeric bound;
`toBeGreaterThanOrEqual` and `toBeLessThanOrEqual` require it inclusive.

```ts
expect(count).toBeGreaterThan(1);
expect(count).toBeLessThanOrEqual(10);
```

#### `toBeCloseTo`

Requires a number within `10 ** -digits / 2` of `expected`.

```ts
expect(totals.lineTotal).toBeCloseTo(60); // digits default: 2
```

`toBeCloseTo(60)` accepts 59.996 and rejects 59.99. Infinite values pass only
when they are the same infinity.

#### Matching a schema

`toMatchSchema` validates a value against a
[Standard Schema](https://standardschema.dev): a Zod, Valibot, or ArkType
schema, or any library that implements the spec. It returns the schema's
output, typed, so the rest of the test reads properties without casting.

```ts

const User = z.object({ id: z.number(), name: z.string(), email: z.email() });

const users = expect(await response.json()).toMatchSchema(z.array(User));
expect(users.map((user) => user.name)).toContain('Ada');
```

- A failure lists every issue by its path (`1.email: Invalid email address`).
- The output is the schema's, so defaults and transforms apply.
- A schema that validates asynchronously (an async refinement) is
  `INVALID_ARGUMENT`.
- Negated, it passes when the value does not match and returns nothing.

#### `toBeOK`

Requires a [`WebResponse`](https://e2e.com/docs/reference/request#webresponse) whose status is
2xx, from 200 to 299. It takes what `request`, `browser.waitForResponse`, and
`route.fetch()` return.

```ts
const created = await request.post('/api/orders', { json: { sku: 'A1' } });
expect(created).toBeOK();
// ASSERTION_FAILED: expected a 2xx status, got 404 from https://shop.test/api/orders
```

- The failure names the status and the origin and path of `response.url`,
  without its credentials, query, or fragment. A URL that is not an absolute
  `http` or `https` one is left out. The body is never read.
- A status number and other types that are not `WebResponse` fail to
  compile, and so does `WebResponse | undefined` under `strictNullChecks`. A
  value typed `any` compiles. In a generic helper, type the parameter as
  `WebResponse`: `R extends WebResponse` does not compile.
- At run time, an object with a numeric `status` and a string `url` is
  checked as a response. A value with either field missing or of another
  type fails as `ASSERTION_FAILED`, negated too.
- To wait for a 2xx status, poll the call:
  `await expect.poll(() => request.get('/api/jobs/7')).toBeOK()`.

#### Failure messages

Pass a second argument to describe the check in its failure message:

```ts
expect(created, 'the company exists through the API').toBeTruthy();
// ASSERTION_FAILED: the company exists through the API: expected undefined to be truthy
```

A [locator](#locator-matchers) or `screen` expectation takes a message the
same way. A `browser` expectation takes none; its failure names the matcher.

#### Not included

The unit-runner matchers (`toThrow`, `toBeInstanceOf`, `toBeNaN`,
`toStrictEqual`, `resolves`, `rejects`, `expect.extend`) are not part of
`expect`. Code-level checks belong in the unit runner.

### Asymmetric matchers

An asymmetric matcher stands in for a value inside `toEqual`,
`toMatchObject`, the collection form of `toContain`, and the value of
`toHaveProperty`. They are Jest's matchers, with Jest's rules.

| Matcher | Matches |
| --- | --- |
| `expect.any(Class)` | An instance of the class. For `String`, `Number`, `Boolean`, `BigInt`, `Symbol`, and `Function`, the primitive too; for `Object`, anything `typeof` calls an object, `null` included |
| `expect.anything()` | Anything but `null` and `undefined` |
| `expect.objectContaining(sample)` | An object whose properties include every property of `sample`, each compared by `toEqual` rules |
| `expect.arrayContaining(sample)` | An array holding every element of `sample`, in any order, each compared by `toEqual` rules |
| `expect.stringContaining(text)` | A string with `text` as a substring |
| `expect.stringMatching(text \| RegExp)` | A string the RegExp tests true on; a text sample is compiled to a RegExp, so `'a.b'` matches `'axb'` |

```ts
expect(created).toEqual({
  id: expect.stringMatching(/^usr_/),
  createdAt: expect.any(String),
  roles: expect.arrayContaining(['member']),
  profile: expect.objectContaining({ name: 'Ada' }),
});
expect(rows).toContain(expect.objectContaining({ status: 'paid' }));
expect(response).toHaveProperty('body.total', expect.any(Number));
```

- In a failure message a matcher prints as its description: `Any<Number>`,
  `ObjectContaining {"name":"Ada"}`.
- Matchers nest: an `objectContaining` sample may hold an `expect.any`.
- The string form of `toContain` refuses them; see [`toContain`](#tocontain).

### Soft assertions

`expect.soft(actual, message?)` takes what `expect(actual, message?)` takes
and returns the same matchers. A soft matcher that fails does not throw: the
failure is kept on the running attempt and the body continues.

```ts
test('checkout summary', async ({ agent, screen }) => {
  await agent.act('add the "Pro" plan to the cart and open the summary');
  expect.soft(await screen.getByTestId('subtotal').textContent()).toBe('$40.00');
  expect.soft(await screen.getByTestId('tax').textContent()).toBe('$8.00');
  await expect.soft(screen.getByRole('button', 'Pay')).toBeEnabled();
  await expect(screen.getByTestId('total')).toHaveText('$48.00');
});
```

```text
ASSERTION_FAILED: 2 soft assertions failed
1. expected "$41.00" to be "$40.00"
2. expect.toBeEnabled failed
   locator: getByRole('button', 'Pay')
   expected: enabled
   observed: states: disabled (match count 1)
```

- Once the body has settled, and before `afterEach`, the attempt fails with
  one `ASSERTION_FAILED` that lists every kept failure in order. The error's
  source line is the first soft matcher that failed.
- A soft locator or `browser` matcher is still a recorded `expect.<matcher>`
  step, marked failed, so the report shows where in the flow it landed.
- A soft value matcher is not a step, the same as a hard one; its failure
  appears in the attempt's error records.
- When the body throws on its own, or times out, that error stays the
  attempt's verdict and the soft failures are recorded beside it under
  `secondaryErrors`.
- A body that skips itself with `test.skip(...)` after a soft failure still
  fails: the soft failures are the attempt's error, and the skip reason is
  kept in the attempt's `skip`.
- A soft `toMatchSchema` returns the schema's output when the value matches
  and `undefined` after a kept failure, and its type says so.

<Note>
Outside a test body there is nothing to keep a failure for, so `expect.soft`
throws at once like `expect`: in a standalone script, and in an `afterEach`
hook, which runs after the soft failures have been settled. There is no
`expect.soft.poll`; `expect.poll` has its own timeout to fail on.
</Note>

### Polling a value

`expect.poll(read)` re-reads a value until a matcher passes. Use it to wait
for an API response or saved data after an app action.

```ts
await agent.act('create a test named "AI checkout regression" described as {description}', {
  params: { description },
});
await expect
  .poll(() => getTest(workspace).then((row) => row?.title), { timeout: 15_000 })
  .toBe('AI checkout regression');
await expect.poll(async () => (await listTests(workspace)).length).toBeGreaterThan(1);
await expect.poll(() => readStatus(), { message: 'the batch never finished' }).not.toBe('running');
```

| Option | Type | Default |
| --- | --- | --- |
| `timeout` | `number` | `config.assertionTimeout` during an attempt or hook, 5000 ms outside both |
| `interval` (deprecated) | `number` | - |
| `intervals` | `readonly number[]` | `[100, 250, 500, 1000]` |
| `message` | `string` | - |

- `timeout` is the deadline in milliseconds, a finite number 0 or more. It is
  capped by the test deadline in the body, or the hook's `cleanupTimeout`
  during `afterEach`. In `beforeAll`, `afterAll`, and worker fixture teardown,
  it is capped by the hook deadline. `0` polls until that cap, so outside a
  test, hook, or hosted session it is `INVALID_CONFIG`. The maximum timeout
  is 2147483647 ms. A hosted session (`openHost()`) defaults to
  `config.assertionTimeout` too.
- `interval` is the pause between reads in milliseconds, a finite number
  above 0. It is deprecated: pass `intervals: [<ms>]`. It will be removed no
  earlier than April 1, 2027.
- `intervals` is a non-empty list of pauses in milliseconds. Each entry
  must be a positive safe integer. Pauses are used in order. The last pause is
  repeated.
- `message` is an extra line in the timeout error, after the matcher line.

Every value matcher is available, returning a promise.

- Each sample calls `read` and runs the matcher. A matcher failure or a
  `read` that throws is one failing sample unless `read` calls `test.skip()`
  or `test.fixme()`; a `read` that hangs is cut at the deadline. Either call
  ends the poll and marks the test skipped.
- `toMatchSchema` resolves to the schema's output for the passing read.
- When the attempt is cancelled, the loop stops with `CANCELLED`. At the
  attempt's deadline the test or hosted session fails with `TEST_TIMEOUT`.
  If a sample failed, the last failure is recorded under `secondaryErrors`
  for a test body or hosted session. For a suite hook or worker fixture
  teardown, the last failure is included in the timeout message.
  A `read` in flight is abandoned, not stopped: work it started can go on,
  except that running steps are cancelled and later step calls are refused.
- `expect.poll` is not recorded as a report step; a timeout surfaces only as
  the test's failure.

At the deadline it throws `ASSERTION_FAILED` naming the matcher, then
`message` when given, then the last sample: the last matcher failure, the
last `read` error, or `no read completed`.

```text
expect.poll(...).not.toBe(...) timed out after 5000 ms
the batch never finished
last: expected "running" not to be "running"
```

| Throws | When |
| --- | --- |
| `ASSERTION_FAILED` | The deadline passed without a passing sample |
| `INVALID_CONFIG` | Options not a plain object, an unknown option, `timeout`, `interval`, or `intervals` out of range, or both `interval` and `intervals` set, before the first read |
| `CANCELLED` | The attempt was cancelled or timed out |
| `STEP_NOT_AWAITED` | The phase that started the poll returned while it still ran |
| `HOOK_FAILED` | A `beforeAll` or `afterAll` hook returned while its poll still ran |

<Note>
Await every poll. A poll belongs to the phase that started it: the test body
(with its fixtures and `beforeEach` hooks), one `afterEach` hook or fixture
teardown, or one `beforeAll` or `afterAll` hook. When that phase returns
while the poll still runs, the poll is cancelled and the phase fails with
`STEP_NOT_AWAITED` at the line of the call, whether or not the poll would
have passed. A body that threw keeps its own error and records this one
under `secondaryErrors`, and a suite hook reports it as `HOOK_FAILED`.
</Note>

A poll never fails a later test: a poll started by work its phase left
running, such as a body past its timeout, is cancelled before its first
read.

### Retrying a block

`expect(fn).toPass()` retries a block until it stops throwing. Use it when
several assertions must pass in the same try. For a single changing value,
use [`expect.poll`](#polling-a-value).

```ts
await expect(async () => {
  const response = await fetch(`${app.baseUrl}/api/orders/42`);
  expect(response.status).toBe(200);
  await expect(screen.getByRole('status')).toHaveText('Ready', { timeout: 200 });
}, 'the order is ready').toPass({ timeout: 5_000 });
```

| Option | Type | Default |
| --- | --- | --- |
| `timeout` | `number` | [`config.toPass.timeout`](https://e2e.com/docs/reference/config#topass), or `0` |
| `intervals` | `readonly number[]` | [`config.toPass.intervals`](https://e2e.com/docs/reference/config#topass), or `[100, 250, 500, 1000]` |

- `timeout` is the deadline in milliseconds, from 0 through 2147483647. At
  `0` there is no timeout, and the block is retried until the test or hook
  deadline. Outside a test, hook, or hosted session (`openHost()`), a
  positive `timeout` is required.
- `intervals` is the list of pauses between tries, in milliseconds. Each
  entry must be a positive safe integer. The last entry repeats.

Each try calls the block and awaits it.

- A try fails when the block throws or its promise rejects, except when it
  calls `test.skip()` or `test.fixme()`. Either call ends the retry and marks
  the test skipped. The block is called again after the next pause if the
  try fails.
- `.not.toPass()` passes on the first try that fails. It fails at the
  deadline when every try passed.
- `expect.soft(fn).toPass()` keeps a timeout as a soft failure, and the test
  body continues.
- `expect(fn, message)` adds `message` to the timeout error.
- Await every `toPass` call. The rules are the same as for
  [a poll](#polling-a-value).

Inside the block:

- A locator matcher waits its full assertion timeout on each try. Give it a
  short `timeout` so more tries fit before the deadline.
- `expect.soft` never fails a try, because its failures are kept for the end
  of the test body. Use `expect`.
- Steps from every try appear in the report, so a test that passed can show
  failed steps from its early tries.
- When a try fails or is cut at the deadline, steps still running in it are
  cancelled. Later step calls from that try are refused.

At the deadline it throws `ASSERTION_FAILED` naming the call, then `message`
when given, then the last error.

```text
expect(...).toPass() timed out after 5000 ms
the order is ready
last: expected 202 to be 200
```

The last line is `last: no try completed` when no try finished, and
`last: the block passed` for `.not.toPass()`.

With no `timeout`, a block that never passes runs until the test times out.
The error is then `TEST_TIMEOUT`, or the hook's timeout error in a hook.
If a try failed, the block's last error is recorded under `secondaryErrors`
for a test body or hosted session. For a suite hook or worker fixture
teardown, the last error is included in the timeout message.

| Throws | When |
| --- | --- |
| `ASSERTION_FAILED` | The deadline passed without a passing try |
| `INVALID_ARGUMENT` | The value given to `expect` is not a function |
| `INVALID_CONFIG` | Options not a plain object, an unknown option, `timeout` or `intervals` out of range, or no positive `timeout` outside a test or hook, before the first try |
| `CANCELLED` | The attempt was cancelled or timed out |
| `STEP_NOT_AWAITED` | The phase that started the call returned while it still ran |
| `HOOK_FAILED` | A `beforeAll` or `afterAll` hook returned while its call still ran |

## Behavior

### Timeouts and failures

| Property | Value |
| --- | --- |
| Default timeout | [`config.assertionTimeout`](https://e2e.com/docs/reference/config#assertiontimeout) |
| Override | `{ timeout }` in milliseconds, on every locator and `browser` matcher |
| Unknown option | `INVALID_ARGUMENT`; see [Option validation](#option-validation) |
| Failure code | `ASSERTION_FAILED`, exit code 1 |

### Negation

`.not` inverts a matcher. A negated matcher passes on the first read that
satisfies the negation, as in Playwright, and fails when none does before the
timeout.

### Strictness

- A positive locator matcher requires exactly one match. The exceptions are
  `toHaveCount` and the list form of `toHaveText` and `toContainText`.
- Zero matches keep polling until the timeout, except for the matchers below
  that accept them.
- Multiple matches fail immediately with `LOCATOR_AMBIGUOUS`.
- `toBeHidden`, `toBeVisible({ visible: false })`,
  `toBeAttached({ attached: false })`, negated visibility, negated
  `toBeAttached`, and negated `toBeInViewport` accept zero matches.
- For those, for `toHaveCount` and the list forms, and for
  `waitFor({ state: 'detached' })` and `'hidden'`, a locator under a frame
  that is not in the document is zero matches rather than a wait for the
  frame. `toHaveCount(0)` passes after an iframe closes.

### Text matching

- Text comparison is normalized: leading and trailing whitespace is trimmed
  and each run of whitespace collapses to one space.
- `toHaveText` and `toContainText` read the same rendered text as
  [`textContent()`](https://e2e.com/docs/reference/screen#locator-reads), `innerText` on the web.
- A `TextMatch` string matches exactly. A `RegExp` uses its own source and
  flags. Anything else, such as a predicate function, is `INVALID_ARGUMENT`.
- `ignoreCase: true` on `toHaveText`, `toContainText`, `toHaveAccessibleName`,
  and the value form of `toHaveAttribute` compares a string case-insensitively
  and adds the `i` flag to a `RegExp`; `ignoreCase: false` removes it.
- `toHaveAttribute(name, value)` compares like `toHaveText`, after
  normalization.
- [`toHaveValue`](#tohavevalue) is the exception: it compares a value as it
  is.

### Secure fields

A secure field, such as a password input, is never judged: the engine
withholds its value and text.

| Matcher | On a secure field |
| --- | --- |
| `toHaveValue`, `toHaveText`, `toContainText`, `toBeEmpty` | `POLICY_DENIED`, like `inputValue()` and `textContent()`, negated or in list form too |
| `toHaveAttribute` | `POLICY_DENIED`, like `getAttribute()`, for every attribute name and negated too |
| `toHaveAccessibleName`, `toHaveRole`, and the state matchers | Answer as usual |

Assert the outcome of the fill, not the field.

### Option validation

- A matcher refuses any option key it does not take, and a flag that is not a
  boolean, with `INVALID_ARGUMENT` before it reads the screen. `e2e run` does
  not type-check, so this is the check a JavaScript test or a computed option
  object gets.
- Playwright options e2e does not implement, such as `indeterminate` on
  `toBeChecked` or `useInnerText` on `toHaveText`, fail this way instead of
  passing on the default.
- The boolean options Playwright gives these matchers (`checked`, `enabled`,
  `visible`, `attached`) work the same way here.

## Types

### `ExpectCall`, `SoftExpectCall`, and `Expect`

```ts
type NotAny<T> = 0 extends 1 & T ? never : T;

export interface ExpectCall {
  <L extends Locator>(actual: NotAny<L>, message?: string): AsyncExpectation;
  <S extends Screen>(actual: NotAny<S>, message?: string): ScreenExpectation;
  <E extends object>(actual: Expectable<E>): E;
  <F extends () => unknown>(actual: NotAny<F>, message?: string): PassExpectation<F>;
  <T>(actual: T, message?: string): ValueExpectation<T>;
}

export interface SoftExpectCall {
  <L extends Locator>(actual: NotAny<L>, message?: string): AsyncExpectation;
  <S extends Screen>(actual: NotAny<S>, message?: string): ScreenExpectation;
  <E extends object>(actual: Expectable<E>): E;
  <F extends () => unknown>(actual: NotAny<F>, message?: string): PassExpectation<F, SoftValueExpectation<F>>;
  <T>(actual: T, message?: string): SoftValueExpectation<T>;
}

export interface Expect extends ExpectCall {
  poll<T>(read: () => T | Promise<T>, options?: PollOptions): PollExpectation<T>;
  readonly soft: SoftExpectCall;
  any(sample: Class | typeof BigInt | typeof Symbol): AsymmetricMatcher;
  anything(): AsymmetricMatcher;
  objectContaining(sample: object): AsymmetricMatcher;
  arrayContaining(sample: readonly unknown[]): AsymmetricMatcher;
  stringContaining(sample: string): AsymmetricMatcher;
  stringMatching(sample: string | RegExp): AsymmetricMatcher;
}
```

### `AsyncExpectation` and `TextMatcherOptions`

```ts
export interface AsyncExpectation {
  readonly not: AsyncExpectation;
  toBeVisible(options?: { visible?: boolean; timeout?: number }): Promise<void>;
  toBeHidden(options?: { timeout?: number }): Promise<void>;
  toBeInViewport(options?: { ratio?: number; timeout?: number }): Promise<void>;
  toBeAttached(options?: { attached?: boolean; timeout?: number }): Promise<void>;
  toBeEnabled(options?: { enabled?: boolean; timeout?: number }): Promise<void>;
  toBeDisabled(options?: { timeout?: number }): Promise<void>;
  toBeEditable(options?: { editable?: boolean; timeout?: number }): Promise<void>;
  toBeChecked(options?: { checked?: boolean; timeout?: number }): Promise<void>;
  toBeSelected(options?: { timeout?: number }): Promise<void>;
  toBeExpanded(options?: { timeout?: number }): Promise<void>;
  toBeFocused(options?: { timeout?: number }): Promise<void>;
  toBeEmpty(options?: { timeout?: number }): Promise<void>;
  toHaveText(expected: TextMatch, options?: TextMatcherOptions): Promise<void>;
  toHaveText(expected: readonly TextMatch[], options?: TextMatcherOptions): Promise<void>;
  toContainText(expected: TextMatch, options?: TextMatcherOptions): Promise<void>;
  toContainText(expected: readonly TextMatch[], options?: TextMatcherOptions): Promise<void>;
  toHaveValue(expected: TextMatch, options?: { timeout?: number }): Promise<void>;
  toHaveAttribute(name: string, options?: { timeout?: number }): Promise<void>;
  toHaveAttribute(name: string, value: TextMatch, options?: TextMatcherOptions): Promise<void>;
  toHaveCount(expected: number, options?: { timeout?: number }): Promise<void>;
  toHaveAccessibleName(expected: TextMatch, options?: TextMatcherOptions): Promise<void>;
  toHaveRole(role: Role | RoleAlias, options?: { timeout?: number }): Promise<void>;
  toHaveScreenshot(name: string, options?: ScreenshotOptions): Promise<void>;
  toHaveScreenshot(options?: ScreenshotOptions): Promise<void>;
}

export interface TextMatcherOptions {
  ignoreCase?: boolean;
  timeout?: number;
}
```

### `ScreenExpectation` and `ScreenshotOptions`

```ts
export interface ScreenExpectation {
  readonly not: ScreenExpectation;
  toHaveScreenshot(name: string, options?: ScreenshotOptions): Promise<void>;
  toHaveScreenshot(options?: ScreenshotOptions): Promise<void>;
}

export interface ScreenshotOptions {
  threshold?: number;
  maxDiffPixels?: number;
  maxDiffPixelRatio?: number;
  mask?: readonly Locator[];
  maskColor?: string;
  timeout?: number;
}
```

### `BrowserExpectation`

```ts
export interface BrowserExpectation {
  readonly not: BrowserExpectation;
  toHaveURL(expected: string | RegExp, options?: { ignoreCase?: boolean; timeout?: number }): Promise<void>;
  toHaveTitle(expected: TextMatch, options?: { timeout?: number }): Promise<void>;
  toHaveClass(target: Locator, expected: TextMatch, options?: { timeout?: number }): Promise<void>;
}
```

### `ValueExpectation`

```ts
export interface ValueExpectation<T> {
  readonly not: NegatedValueExpectation<T>;
  toBe(expected: T): void;
  toEqual(expected: unknown): void;
  toMatchObject(expected: object): void;
  toBeTruthy(): void;
  toBeFalsy(): void;
  toBeNull(): void;
  toBeUndefined(): void;
  toBeDefined(): void;
  toHaveLength(expected: number): void;
  toHaveProperty(path: PropertyPath, ...expected: [] | [expected: unknown]): void;
  toContain(expected: unknown): void;
  toMatch(expected: string | RegExp): void;
  toBeGreaterThan(expected: number): void;
  toBeGreaterThanOrEqual(expected: number): void;
  toBeLessThan(expected: number): void;
  toBeLessThanOrEqual(expected: number): void;
  toBeCloseTo(expected: number, digits?: number): void;
  toMatchSchema<Schema extends StandardSchemaV1>(schema: Schema): StandardSchemaV1.InferOutput<Schema>;
  toBeOK(...valueIsNotAResponse: [T] extends [WebResponse] ? [] : [never]): void;
}

export type NegatedValueExpectation<T, Back = ValueExpectation<T>> = {
  readonly not: Back;
} & {
  readonly [K in Exclude<keyof ValueExpectation<T>, 'not'>]: (...args: Parameters<ValueExpectation<T>[K]>) => void;
};

export type SoftValueExpectation<T> = Omit<ValueExpectation<T>, 'toMatchSchema' | 'not'> & {
  readonly not: NegatedValueExpectation<T, SoftValueExpectation<T>>;
  toMatchSchema<Schema extends StandardSchemaV1>(schema: Schema): StandardSchemaV1.InferOutput<Schema> | undefined;
};

export type Class = abstract new (...args: never[]) => unknown;

export type PropertyPath = string | readonly (string | number)[];
```

### `AsymmetricMatcher`

```ts
export interface AsymmetricMatcher {
  asymmetricMatch(other: unknown): boolean;
  toString(): string;
}
```

### `PollOptions` and `PollExpectation`

```ts
export interface PollOptions {
  timeout?: number;
  interval?: number;
  intervals?: readonly number[];
  message?: string;
}

export type PollExpectation<T> = {
  readonly not: NegatedPollExpectation<T>;
} & {
  readonly [K in Exclude<keyof ValueExpectation<T>, 'not' | 'toMatchSchema'>]: (
    ...args: Parameters<ValueExpectation<T>[K]>
  ) => Promise<void>;
} & {
  toMatchSchema<Schema extends StandardSchemaV1>(schema: Schema): Promise<StandardSchemaV1.InferOutput<Schema>>;
};

export type NegatedPollExpectation<T> = {
  readonly not: PollExpectation<T>;
} & {
  readonly [K in Exclude<keyof ValueExpectation<T>, 'not'>]: (...args: Parameters<ValueExpectation<T>[K]>) => Promise<void>;
};
```

### `PassOptions` and `PassExpectation`

```ts
export type PassOptions = {
  timeout?: number;
  intervals?: readonly number[];
};

type PassMatcher = {
  toPass(options?: PassOptions): Promise<void>;
};

export type PassExpectation<T, Value = ValueExpectation<T>> = Omit<Value, 'not'> & PassMatcher & {
  readonly not: NegatedValueExpectation<T, PassExpectation<T, Value>> & PassMatcher;
};
```
