Skip to main content

@std/expect@1.0.14
Built and signed on GitHub Actions

Jest compatible `expect` assertion functions

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
3 days ago (1.0.14)

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:

Only these functions are still not available:

  • Matchers:
    • toMatchSnapshot
    • toMatchInlineSnapshot
    • toThrowErrorMatchingSnapshot
    • toThrowErrorMatchingInlineSnapshot

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
View transparency log

Add Package

deno add jsr:@std/expect

Import symbol

import * as expect from "@std/expect";

---- OR ----

Import directly with a jsr specifier

import * as expect from "jsr:@std/expect";

Add Package

npx jsr add @std/expect

Import symbol

import * as expect from "@std/expect";

Add Package

yarn dlx jsr add @std/expect

Import symbol

import * as expect from "@std/expect";

Add Package

pnpm dlx 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";