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

you can now use expectAsync()

Expecting success:

it('expect result', async () => {
   ...
   await expectAsync(someAsyncFunction(goodInput)).toBeResolved(expectedResponse)
})

Expecting failure:

it('expect result', async () => {
   ...
   await expectAsync(someAsyncFunction(badInput)).toBeRejectedWith(expectedResponse)
})

Leave a Comment