Test for expected failure in Mocha
mocha.js, node.js, unit-testing
Solution
You can try using Chai's `throw` construct. For example:
expect(Constructor).to.throw(Error);
Problem
Using Mocha, I am attempting to test whether a constructor throws an error. I haven't been able to do this using the expect syntax, so I'd like to do the following: ``` it('should throw exception when instantiated', function() { try { new ErrorThrowingObject(); // Force the test to fail since error wasn't thrown } catch (error) { // Constructor threw Error, so test succeeded. } } ``` Is this possible?