1.0.0 • Published 9 years ago

expect-to-core v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

expect-to-core

Core assertions for expect-to.

Installation

npm install --save-dev expect-to-core

These are included by default in expect-to, e.g.

import expect, { be, deepEqual } from 'expect-to'

Assertions

  • be — does a === check

    expect('test').to(be('test'));
  • deepEqual — does a deeply equal check using deep-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. neither null nor undefined)

    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/)),
1.0.0

9 years ago

0.8.0

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago