Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/unitest/matcher/mod.ts

🃏 Deno-first universal unit testing framework
Latest
import * as unitest from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/mod.ts";

Variables

Additional jest matchers

jest built-in matcher map

Functions

make nested text

helper for stringify

assert message stringer

expect block stringer

assert stringer

Use .toBe to compare primitive values

Use .toBeAfter when checking if a date occurs after date

Use .toBeAfterOrEqualTo when checking if a date equals to or occurs after date

Use .toBeAnything when checking if a value is not null and undefined.

Use .toBeArray when checking if a value is an Array

Use .toBeBefore when checking if a date occurs before date

Use .toBeBeforeOrEqualTo when checking if a date equals to or occurs before date

Use .toBeBetween when checking if a date equals or occurs after startDate and equals or occurs before endDate

Use .toBeBoolean when checking if a value is a boolean

Use .toBeCloseTo to compare floating point numbers for approximate equality

Use .toBeDate when checking if a value is a Date

Use .toBeDateString when checking if a value is a valid date string

Use .toBeDefined to check that a variable is not undefined

Use .toBeEmpty when checking if a String '', Array [], Object {}, or Iterable is empty

Use .toBeEmptyObject when checking if a value is an empty Object

Use .toBeError when checking if a value is Error object or Error extended object.

Use .toBeEven when checking if a value is an even Number

Use .toBeExtensible when checking if an object is extensible

Use .toBeFalse when checking a value is equal (===) to false

Use .toBeFalsy when you don't care what a value is and you want to ensure a value is false in a boolean context

Use .toBeFinite when checking if a value is a number, not NaN or Infinity

Use .toBeFrozen when checking if an object is frozen

Use .toBeFunction when checking if a value is a Function

Use .toBeGreaterThan to compare actual > expected for number or bigint

Use .toBeGreaterThanOrEqual to compare actual >= expected for number or bigint

Use .toBeHexadecimal when checking if a value is a valid HTML hex color

Use .toBeInstanceOf to check that an object is an instance of a class

Use .toBeInteger when checking if a number is an integer

Use .toBeLessThan to compare actual < expected for number or bigint

Use .toBeLessThanOrEqual to compare actual <= expected for number or bigint

Use .toBeNaN when checking a value is NaN

Use .toBeNegative when checking if a value is a negative number

Use .toBeNil when checking a value is null or undefined

Use .toBeNull when checking a value is null

Use .toBeNumber when checking if a value is a number

Use .toBeObject when checking if a value is an Object

Use .toBeOdd when checking if a value is an odd number

Use .toBeOneOf when checking if a value is a member of a given Array

Use .toBePositive when checking if a value is a positive number

Use .toBeSealed when checking if an value is sealed

Use .toBeString when checking if a value is a string

Use .toBeSymbol when checking if a value is a symbol

Use .toBeTrue when checking a value is true

Use .toBeTruthy when you don't care what a value is and you want to ensure a value is true in a boolean context

Use .toBeUndefined to check that a value is undefined

Use .toBeValidDate when check that a Date is valid

Use .toBeWithin when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive)

Use .toContain when you want to check that an item is in an array

Use .toContainAnyEntries when checking if an object contains at least one of the provided entries

Use .toContainAnyKeys when checking if an object contains at least one of the provided keys

Use .toContainAnyValues when checking if an object contains at least one of the provided values

Use .toContainEntries when checking if an object contains all of the provided entries

Use .toContainEntry when checking if an object contains the provided entry

Use .toContainEqual when you want to check that an item with a specific structure and values is contained in an array

Use .toContainKeys when checking if an object has all of the provided keys

Use .toContainValue when checking if an object contains the provided value

Use .toContainValues when checking if an object contains all of the provided values

Use .toEndWith when checking if a string ends with a given string suffix

Use .toEqual to compare recursively all properties of object instances

Use .toEqualCaseInsensitive when checking if a string is equal to another ignoring the casing of both strings

Use .toEqualIgnoringWhitespace when checking if a string is equal to another string ignoring white-space.

Use .toHaveBeenCalled to ensure that a mock object got called

Use .toHaveBeenCalledAfter when checking if a mock object was called after another mock object

Use .toHaveBeenCalledBefore when checking if a mock object was called before another mock object

Use .toHaveBeenCalledOnce to check if a mock object was called exactly one time

Use .toHaveBeenCalledTimes to ensure that a mock object got called exact number of times

Use .toHaveBeenCalledWith to ensure that a mock function was called with specific arguments

Use .toHaveBeenLastCalledWith to test mock object was last called with

Use .toHaveBeenNthCalledWith to test mock object was nth called with

Use .toHaveLastReturnedWith to test the specific value that a mock object last returned

Use .toHaveLength to check that an object has a .length property and it is set to a certain numeric value

Use .toHaveNthReturnedWith to test the specific value that a mock object returned for the nth call

Use .toHaveProperty to check if property at provided reference keyPath exists for an object

Use .toHaveReturned that the mock object successfully returned at least one time

Use .toHaveReturnedTimes to ensure that a mock object returned successfully an exact number of times

Use .toHaveReturnedWith to ensure that a mock object returned a specific value

Use .toInclude when checking if a string includes the given string substring

Use .toIncludeAllMembers when checking if an array contains all of the same members of a given set

Use .toIncludeAnyMembers when checking if an array contains any of the members of a given set

Use .toIncludeMultiple when checking if a string includes all of the given substrings

Use .toIncludeRepeated when checking if a string includes the given string substring the correct number of times

Use .toIncludeSameMembers when checking if two arrays contain equal values, in any order

Use .toMatch to check that a string matches a regular expression

Use .toMatchObject to check that a object matches a subset of the properties of an object

Use .toSatisfy when you want to use a custom matcher by supplying a predicate function that returns a boolean.

Use .toSatisfyAll when you want to use a custom matcher by supplying a predicate function that returns a boolean for all values in an array

Use .toSatisfyAny when you want to use a custom matcher by supplying a predicate function that returns true for any matching value in an array

Use .toStartWith when checking if a String starts with a given String prefix

Use .toThrow to test that a function throws when it is called