Skip to main content
Module

std/expect/mod.ts

Deno standard library
Go to Latest
import * as mod from "https://deno.land/std@0.210.0/expect/mod.ts";

Examples

Example 1

import { expect } from "https://deno.land/std@0.210.0/expect/mod.ts";

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 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.