(node:17068) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1):

497 views
Skip to first unread message

Srikanth Desia

unread,
Apr 13, 2017, 2:53:46 PM4/13/17
to Jasmine
Complete error is below

(node:17068) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: 'expect' was used when there was no current sp
ec, this could be because an asynchronous test timed out

Could anyone let me know ..


describe("Calling a rest api get", () => {
    it("Get call"function(done) {
        RestApi.sendRequest("http://www.google.com").then ((responseany=> {
            console.log(response);
            expect(response).toEqual(300);
            done();
        });
    });
});

When you handle the exception by adding catch ((error: any) => {});  . you will not be see that exception

my test case is expected to fail . 200 is not equal to 300. But always its passing.

Gregg Van Hove

unread,
Apr 14, 2017, 4:38:31 PM4/14/17
to jasmi...@googlegroups.com
It sounds like that `RestApi.sendRequest` promise is getting rejected for some reason, and since there is no handler, you're seeing this warning. This would also explain why the spec is failing, since Jasmine isn't seeing any failures within the spec. You should be able to register `done.fail` as the rejection handler for the promise and that will fail the spec immediately and cause Jasmine to move on to the next spec in your suite.

Hope this helps. Thanks for using Jasmine!

-Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+unsubscribe@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages