vendredi 9 septembre 2016

Async/Await throw an error in Mocha

I'm trying to catch an error which should be throw by the function getUserRecommendations. This is my example:

it('should throw an error when no user ID is provided', (done) => {
  expect(async () => {
    await Client.getUserRecommendations(null, {})
  }).to.throw(/Missing/)
})

Unfortunately it doesn't work and I get as result that my test it doesn't pass along with this message:

AssertionError: expected [Function] to throw an error

Aucun commentaire:

Enregistrer un commentaire