unexpected-promise

1.3.0 • Public • Published

unexpected-promise

Plugin for the Unexpected assertion lib adding Promise support. Requires Unexpected 7 or above.

NPM version Build Status Coverage Status Dependency Status

An unexpected promise

var expect = require('unexpected').installPlugin(require('unexpected-promise'));
 
it('should DTRT', function () {
    return expect(myPromise, 'to be resolved with', 'foobar');
});
 
it('should fail', function () {
    return expect(myPromise, 'to be rejected with', new Error('argh'));
});

Alternatively you can use the when resolved and when rejected assertions to replace the subject with the resolved value or rejection reason, then apply another assertion to it:

it('should DTRT', function () {
    return expect(myPromise, 'when resolved', 'to equal', 'foobar');
});
 
it('should fail', function () {
    return expect(myPromise, 'when rejected', 'to have property', 'message', 'argh');
});

License

Unexpected-promise is licensed under a standard 3-clause BSD license -- see the LICENSE file for details.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.3.0
    2
    • latest

Version History

Package Sidebar

Install

npm i unexpected-promise

Weekly Downloads

13

Version

1.3.0

License

BSD

Last publish

Collaborators

  • munter
  • joelmukuthu
  • gustavnikolaj
  • alexjeffburke
  • papandreou
  • sunesimonsen