@joytest/expect
v3.0.1
Published
Assertion module for joytest.
Downloads
1
Readme
@joytest/expect
Small assertion module.
|Function|Description|Since|
|:---|:---|:---|
|💥 expect(a
).toBe(b
)|Asserts that a
and b
are the same (===
).💥 Throws if assertion failed.|v1.0.0|
|💥 expect(a
).toBeInstanceOf(b
)|Asserts that a
is an instance of b
.💥 Throws if assertion failed.|v1.0.0|
|💥 expect(a
).toEqual(b
)|If b
is a primitive then:a === b
If b
is not a primitive:• Asserts same prototype• Asserts same properties• Asserts property value recursively with toEqual
.💥 Throws if assertion failed.|v1.0.0|
|💥 expect(a
).toHaveProperty(b
)|Asserts that object a
has an enumerable/non-enumerable property called b
.💥 Throws if assertion failed.|v1.0.0|
|💥 expect(a
).toHaveSubString(b
)|Asserts that string a
contains the sub-string b
.💥 Throws if assertion failed.|v1.0.0|
|💥 expect(fn
).toThrowError()|Asserts that fn
throws an error.💥 Throws if assertion failed.|v1.0.0|
|💥 expect(fn
).toThrowError(message
)|Asserts that fn
throws an error with a message containing message
.💥 Throws if assertion failed.|v1.0.0|
|💥 expect.assertions(num
)|Sets how many expect()
function calls are expected.💥 Throws if expect.assertions
is already set.|v1.0.0|
All assertions (except toThrowError
) can be negated with .not
:
expect(1).not.toBe(2)
Example usage:
import {createExpectationsContext} from "@joytest/expect"
const {expect, end} = createExpectationsContext()
expect(1).toBe(1)
end()