Remix
Remix
remix/assert · FunctionView Source

expect

Summary

jest/vitest-style expect API. Returns an object of matchers that throw AssertionError on failure. Supports .not for negation and .rejects / .resolves for asserting on promises.

Mock-aware matchers (toHaveBeenCalled*) read received.mock.calls[i].arguments, which is the shape produced by mock.fn() from @remix-run/test.

Signature

const expect: (received: unknown) => Expectation;

Example

expect(value).toBe(42);
expect(value).not.toBeNull();
expect(value).toEqual(expect.objectContaining({ success: true }));
await expect(fetch("/missing")).rejects.toThrow("Not found");
await expect(loadModule()).resolves.toBeUndefined();

Parameters

received

The value or function or promise to assert against.

Returns

An Expectation object exposing matchers, .not, .rejects, and .resolves.