1.0.0 • Published 9 years ago
expect-to-core v1.0.0
expect-to-core
Core assertions for expect-to.
Installation
npm install --save-dev expect-to-coreThese are included by default in expect-to, e.g.
import expect, { be, deepEqual } from 'expect-to'Assertions
be— does a===checkexpect('test').to(be('test'));deepEqual— does a deeply equal check usingdeep-eqlexpect({ foo: 'bar' }).to(deepEqual({ foo: 'bar' }));notexpect('test').to(not(be('testing')));beTruthyexpect('test').to(beTruthy); expect(null).to(not(beTruthy));beFalsyexpect('').to(beFalsy); expect('foo').to(not(beFalsy));exist(i.e. neithernullnorundefined)expect('test').to(exist); expect(null).to(not(exist));beEmptyexpect([]).to(beEmpty);containexpect([1,2,3]).to(contain(2));beInstanceOfexpect(new Date()).to(beInstanceOf(Date));beTypeexpect(true).to(beType('boolean')); expect('foo').to(beType('string'));matchexpect('TeSt').to(match(/test/i));throwErrorexpect(() => { throw new Error() }).to(throwError()), expect(() => { throw new Error() }).to(throwError(Error)), expect(() => { throw new Error('foo') }).to(throwError(Error, 'foo')), expect(() => { throw new Error('foo') }).to(throwError('foo')), expect(() => { throw new Error('foo') }).to(throwError(/foo/)),