Works with
•JSR Score47%•It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun




Downloads2/wk
•Published3 years ago (0.215.0)
This module provides jest compatible expect assertion functionality.
Currently this module supports the following matchers:
toBetoEqualtoStrictEqualtoMatchtoMatchObjecttoBeDefinedtoBeUndefinedtoBeNulltoBeNaNtoBeTruthytoBeFalsytoContaintoContainEqualtoHaveLengthtoBeGreaterThantoBeGreaterThanOrEqualtoBeLessThantoBeLessThanOrEqualtoBeCloseTotoBeInstanceOftoThrowtoHavePropertytoHaveLength
Also this module supports the following mock related matchers:
toHaveBeenCalledtoHaveBeenCalledTimestoHaveBeenCalledWithtoHaveBeenLastCalledWithtoHaveBeenNthCalledWithtoHaveReturnedtoHaveReturnedTimestoHaveReturnedWithtoHaveLastReturnedWithtoHaveNthReturnedWith
The following matchers are not supported yet:
toMatchSnapShottoMatchInlineSnapShottoThrowErrorMatchingSnapShottoThrowErrorMatchingInlineSnapShot
The following asymmetric matchers are not supported yet:
expect.anythingexpect.anyexpect.arrayContainingexpect.not.arrayContainingexpect.closedToexpect.objectContainingexpect.not.objectContainingexpect.stringContainingexpect.not.stringContainingexpect.stringMatchingexpect.not.stringMatching
The following uitlities are not supported yet:
expect.assertionsexpect.hasAssertionsexpect.addEqualityTesterexpect.addSnapshotSerializerexpect.extend
This module is largely inspired by x/expect module by Allain Lalonde.
Examples
Example 1
Example 1
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);
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";