Core assertions for expect-to.
npm install --save-dev expect-to-core
These are included by default in expect-to
, e.g.
import expect, { be, deepEqual } from 'expect-to'
-
be
— does a===
checkexpect('test').to(be('test'));
-
deepEqual
— does a deeply equal check usingdeep-eql
expect({ foo: 'bar' }).to(deepEqual({ foo: 'bar' }));
-
not
expect('test').to(not(be('testing')));
-
beTruthy
expect('test').to(beTruthy); expect(null).to(not(beTruthy));
-
beFalsy
expect('').to(beFalsy); expect('foo').to(not(beFalsy));
-
exist
(i.e. neithernull
norundefined
)expect('test').to(exist); expect(null).to(not(exist));
-
beEmpty
expect([]).to(beEmpty);
-
contain
expect([1,2,3]).to(contain(2));
-
beInstanceOf
expect(new Date()).to(beInstanceOf(Date));
-
beType
expect(true).to(beType('boolean')); expect('foo').to(beType('string'));
-
match
expect('TeSt').to(match(/test/i));
-
throwError
expect(() => { 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/)),