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); Copy
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:
toBe
toEqual
toStrictEqual
toMatch
toMatchObject
toBeDefined
toBeUndefined
toBeNull
toBeNaN
toBeTruthy
toBeFalsy
toContain
toContainEqual
toHaveLength
toBeGreaterThan
toBeGreaterThanOrEqual
toBeLessThan
toBeLessThanOrEqual
toBeCloseTo
toBeInstanceOf
toThrow
toHaveProperty
toHaveBeenCalled
toHaveBeenCalledTimes
toHaveBeenCalledWith
toHaveBeenLastCalledWith
toHaveBeenNthCalledWith
toHaveReturned
toHaveReturnedTimes
toHaveReturnedWith
toHaveLastReturnedWith
toHaveNthReturnedWith
expect.anything
expect.any
expect.arrayContaining
expect.objectContaining
expect.closeTo
expect.stringContaining
expect.stringMatching
expect.addSnapshotSerializer
expect.assertions
expect.extend
expect.hasAssertions
Only these functions are still not available:
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.
This module provides Jest compatible expect assertion functionality.
Currently this module supports the following functions:
toBetoEqualtoStrictEqualtoMatchtoMatchObjecttoBeDefinedtoBeUndefinedtoBeNulltoBeNaNtoBeTruthytoBeFalsytoContaintoContainEqualtoHaveLengthtoBeGreaterThantoBeGreaterThanOrEqualtoBeLessThantoBeLessThanOrEqualtoBeCloseTotoBeInstanceOftoThrowtoHavePropertytoHaveBeenCalledtoHaveBeenCalledTimestoHaveBeenCalledWithtoHaveBeenLastCalledWithtoHaveBeenNthCalledWithtoHaveReturnedtoHaveReturnedTimestoHaveReturnedWithtoHaveLastReturnedWithtoHaveNthReturnedWithexpect.anythingexpect.anyexpect.arrayContainingexpect.objectContainingexpect.closeToexpect.stringContainingexpect.stringMatchingexpect.addSnapshotSerializerexpect.assertionsexpect.extendexpect.hasAssertionsOnly these functions are still not available:
toMatchSnapshottoMatchInlineSnapshottoThrowErrorMatchingSnapshottoThrowErrorMatchingInlineSnapshotThe 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.