@sz-sw-le1/expect
v1.0.0
Published
Small assertion module.
Downloads
2
Readme
expect
Small assertion module.
|Function|Description|
|:---|:---|
|expect(a
).toBe(b
)|Asserts that a
and b
are the same (===
).|
|expect(a
).toBeInstanceOf(b
)|Asserts that a
is an instance of b
|
|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
|
|expect(a
).toHaveProperty(b
)|Asserts that object a
has an enumerable/non-enumerable property called b
.|
|expect(a
).toHaveSubString(b
)|Asserts that string a
contains the sub-string b
.|
|expect(fn
).toThrowError()|Asserts that fn
throws an error.|
|expect(fn
).toThrowError(message
)|Asserts that fn
throws an error with a message containing message
.|
All assertions (except toThrowError
) can be negated with .not
:
expect(1).not.toBe(2)
Example usage:
const {createExpectationsContext} = require("expect")
const {expect, end} = createExpectationsContext()
expect(1).toBe(1)
end()