javascript - Test if a promise is resolved or rejected with Jasmine in Nodejs -


i know how in mocha want know how jasmine. tried

describe('test promise jasmine', function() {     it('expects rejected promise', function() {         var promise = getrejectedpromise();          // return expect(promise).tobe('rejected');         return expect(promise.inspect().state).tobe('rejected');     }); }); 

however, state pending and, of course, test fails. couldn't find example online make work.

can please me this?

thanks.

to test asynchronous code jasmine should use its async syntax, e.g.:

describe('test promise jasmine', function(done) {     var promise = getrejectedpromise();      promise.then(function() {       // promise resolved       done(new error('promise should not resolved'));     }, function(reason) {       // promise rejected       // check rejection reason if want       done(); // success     }); }); 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -