1.0.0 • Published 3 years ago

@sz-sw-le1/expect v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

expect

Small assertion module.

FunctionDescription
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 === bIf 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()