unexpected-promise
v1.3.0
Published
Plugin for the Unexpected assertion lib adding Promise support
Downloads
69
Readme
unexpected-promise
Plugin for the Unexpected assertion lib adding Promise support. Requires Unexpected 7 or above.
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.