expect-to-promises

expect-to assertions for promises

Usage no npm install needed!

<script type="module">
  import expectToPromises from 'https://cdn.skypack.dev/expect-to-promises';
</script>

README

expect-to-promises

Promise assertions for expect-to.

Installation

npm install --save-dev expect-to-promises

Assertions

  • eventually

    const foo = Promise.resolve('foo');
    
    expect(foo).to(eventually(equal('foo')));
    expect(foo).to(eventually(not(equal('bar'))));
    
    const obj = Promise.resolve({ name: 'kim' });
    expect(obj).to(eventually(deepEqual({ name: 'kim' })));
    
  • beFulfilled

    const foo = Promise.resolve('foo');
    expect(foo).to(beFulfilled);
    
  • beRejected

    const err = Promise.reject(new Error('bar'));
    expect(err).to(beRejected);