So I was trying to configure mocha as the test framework for a javascript project I am working on, and I hit upon the strange fact that you have to use a seperate assertion framework. Mocha's documentation on assertions states that it's designed to work with any assertion framework, which is a laudable goal, but why does it not provide any built in assertion methods? I just struggle to think of any use case where you would want a testing framework, but no way to pass or fail a test.
As Jeff mentioned the designers of Mocha left their users the choice of using any assertion library at all. As to why no default assertions, because Mocha does not need it to work. Execute the following test:
var a = 1;
it("test", function () {
if (a !== 2)
throw new Error("a should equal 2");
});
You get the output:
1) test
0 passing (3ms)
1 failing
1) test:
Error: a should equal 2
[...]
It works just fine without an assertion library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With