Fail a test with Chai.js

Sionnach733 picture Sionnach733 · Nov 17, 2015 · Viewed 27.4k times · Source

In JUnit you can fail a test by doing:

fail("Exception not thrown");

What's the best way to achieve the same using Chai.js?

Answer

Dmytro Shevchenko picture Dmytro Shevchenko · Nov 17, 2015

There's assert.fail(). You can use it like this:

assert.fail(0, 1, 'Exception not thrown');