Skip to main content
Home

@std/expect@1.0.17
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
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:

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

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

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

pnpm i jsr:@std/expect
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/expect

Import symbol

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

Add Package

yarn add jsr:@std/expect
or (using Yarn 4.8 or older)
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";