Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
denoland/stdJest compatible `expect` assertion functions
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
94%
Published
5 months ago (1.0.17)
This module provides Jest compatible expect assertion functionality.
import { expect } from "@std/expect"; const x = 6 * 7; expect(x).toEqual(42); expect(x).not.toEqual(0); await expect(Promise.resolve(x)).resolves.toEqual(42);
Currently this module supports the following functions:
- Common matchers:
toBetoEqualtoStrictEqualtoMatchtoMatchObjecttoBeDefinedtoBeUndefinedtoBeNulltoBeNaNtoBeTruthytoBeFalsytoContaintoContainEqualtoHaveLengthtoBeGreaterThantoBeGreaterThanOrEqualtoBeLessThantoBeLessThanOrEqualtoBeCloseTotoBeInstanceOftoThrowtoHaveProperty
- Mock related matchers:
toHaveBeenCalledtoHaveBeenCalledTimestoHaveBeenCalledWithtoHaveBeenLastCalledWithtoHaveBeenNthCalledWithtoHaveReturnedtoHaveReturnedTimestoHaveReturnedWithtoHaveLastReturnedWithtoHaveNthReturnedWith
- Asymmetric matchers:
- Utilities:
expect.addSnapshotSerializerexpect.assertionsexpect.addEqualityTesterexpect.extendexpect.hasAssertions
Only these functions are still not available:
- Matchers:
toMatchSnapshottoMatchInlineSnapshottoThrowErrorMatchingSnapshottoThrowErrorMatchingInlineSnapshot
The tracking issue to add support for unsupported parts of the API is https://github.com/denoland/std/issues/3964.
This module is largely inspired by x/expect module by Allain Lalonde.
Built and signed on
GitHub Actions
Add Package
deno add jsr:@std/expect
Import symbol
import * as expect from "@std/expect";
Import directly with a jsr specifier
import * as expect from "jsr:@std/expect";
Add Package
pnpm i jsr:@std/expect
pnpm dlx jsr add @std/expect
Import symbol
import * as expect from "@std/expect";
Add Package
yarn add jsr:@std/expect
yarn dlx jsr add @std/expect
Import symbol
import * as expect from "@std/expect";
Add Package
vlt install jsr:@std/expect
Import symbol
import * as expect from "@std/expect";
Add Package
npx jsr add @std/expect
Import symbol
import * as expect from "@std/expect";
Add Package
bunx jsr add @std/expect
Import symbol
import * as expect from "@std/expect";