Await unwraps Promise and maps promise reject to throw, so you can catch it in try..catch so you should get there thrown error.
After second thought exception in this case is thrown before passing it to expect.
Better solution would be to wrap it in try catch block and test error that is caught.
You really want to make sure what error is caught, because you might get also other issue, like TypeError, and test will pass
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It just should be
expect(await fetchItem(3)).to.eventually.throw()
Unfortunately this doesn't work and just leads to the same issue. We're expecting a rejected promise with an error, not just an error.
Await unwraps Promise and maps promise reject to throw, so you can catch it in try..catch so you should get there thrown error.
After second thought exception in this case is thrown before passing it to expect.
Better solution would be to wrap it in try catch block and test error that is caught.
You really want to make sure what error is caught, because you might get also other issue, like TypeError, and test will pass