Skip to content
This repository was archived by the owner on Dec 7, 2020. It is now read-only.

unexpectedjs/unexpected-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unexpected-promise

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

NOTE: THIS MODULE SHOULD BE CONSIDERED DEPRECATED AS UNEXPECTED 8.5.0+ HAS THE FEATURES BUILT-IN!

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.

About

Plugin for the Unexpected assertion lib adding Promise support

Resources

License

Stars

Watchers

Forks

Packages

No packages published