@sz-sw-le1/expect

1.0.0 • Public • Published

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()

Readme

Keywords

none

Package Sidebar

Install

npm i @sz-sw-le1/expect

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

29.3 kB

Total Files

39

Last publish

Collaborators

  • sz-coder