Chai: expecting an error or not depending on a parameter [duplicate]
问题 This question already has answers here : Mocha / Chai expect.to.throw not catching thrown errors (6 answers) Closed 2 years ago . I've been trying to do a text of a function that handles errors in a way that, if it is a valid error, it is thrown, but if it is not, then nothing is thrown. The problem is that i cant seem to set the parameter while using: expect(handleError).to.throw(Error); The ideal would be to use: expect(handleError(validError)).to.throw(Error); Is there any way to achieve