Nebulous Puffy Marshmallows

    expect-to-core

    1.0.0 • Public • Published

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

    Install

    npm i expect-to-core

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • kimjoar