jasmine-node-promise-matchers
v0.2.0
Published
Jasmine Promise matchers for node.
Downloads
57
Maintainers
Readme
Jasmine Node Promise Matchers
Custom jasmine matchers for javascript Promises.
Install
Get it from npm.
npm i jasmine-node-promise-matchers --save-dev
Add matchers to tests
beforeEach(function() {
jasmine.addMatchers(require('jasmine-node-promise-matchers'));
});
Usage
it('is thenable', function() {
var deferred = Promise.resolve();
var thenable = { then: function () {} };
expect(deferred).toBeThenable();
expect(thenable).toBeThenable();
});
it('resolves', function(done) {
var deferred = new Promise(function(resolve) {
resolve();
});
expect(deferred).toResolve(done)
});
it('resolves with value', function(done) {
var deferred = new Promise(function(resolve) {
resolve('value');
});
expect(deferred).toResolveWith('value', done)
});
it('rejects', function(done) {
var deferred = new Promise(function(resolve, reject) {
reject();
});
expect(deferred).toReject(done)
});
it('rejects with value', function(done) {
var deferred = new Promise(function(resolve, reject) {
reject('value');
});
expect(deferred).toRejectWith('value', done)
});
License
ISC