Skip to main content

@std/expect@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score47%
Published2 years ago (0.215.0)

This module provides jest compatible expect assertion functionality.

Currently this module supports the following matchers:

  • toBe
  • toEqual
  • toStrictEqual
  • toMatch
  • toMatchObject
  • toBeDefined
  • toBeUndefined
  • toBeNull
  • toBeNaN
  • toBeTruthy
  • toBeFalsy
  • toContain
  • toContainEqual
  • toHaveLength
  • toBeGreaterThan
  • toBeGreaterThanOrEqual
  • toBeLessThan
  • toBeLessThanOrEqual
  • toBeCloseTo
  • toBeInstanceOf
  • toThrow
  • toHaveProperty
  • toHaveLength

Also this module supports the following mock related matchers:

  • toHaveBeenCalled
  • toHaveBeenCalledTimes
  • toHaveBeenCalledWith
  • toHaveBeenLastCalledWith
  • toHaveBeenNthCalledWith
  • toHaveReturned
  • toHaveReturnedTimes
  • toHaveReturnedWith
  • toHaveLastReturnedWith
  • toHaveNthReturnedWith

The following matchers are not supported yet:

  • toMatchSnapShot
  • toMatchInlineSnapShot
  • toThrowErrorMatchingSnapShot
  • toThrowErrorMatchingInlineSnapShot

The following asymmetric matchers are not supported yet:

  • expect.anything
  • expect.any
  • expect.arrayContaining
  • expect.not.arrayContaining
  • expect.closedTo
  • expect.objectContaining
  • expect.not.objectContaining
  • expect.stringContaining
  • expect.not.stringContaining
  • expect.stringMatching
  • expect.not.stringMatching

The following uitlities are not supported yet:

  • expect.assertions
  • expect.hasAssertions
  • expect.addEqualityTester
  • expect.addSnapshotSerializer
  • expect.extend

This module is largely inspired by x/expect module by Allain Lalonde.

Examples

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);

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