chaijs / chai-as-promised

Extends Chai with assertions about promises.
MIT License
1.42k stars 112 forks source link

rejectedWith when error is undefined doesn't work #263

Closed fishcharlie closed 4 months ago

fishcharlie commented 4 years ago

The following test doesn't work.

it("Should throw an error", async () => {
    return expect(Promise.reject()).to.be.rejectedWith("Error");
});

Instead of giving details about what went wrong (explaining that it expected the error to be "Error" but instead got undefined), it gives a very un-detailed internal error message as shown below:

TypeError: Cannot read property 'message' of undefined
   at Object.compatibleMessage (node_modules/check-error/index.js:78:71)
   at getBasePromise.then.reason (node_modules/chai-as-promised/lib/chai-as-promised.js:191:77)