insist: Better assertions for nodejs
insist: Better assertions for nodejs
There’s plenty of assertion libraries out there that give you all brand-new APIs with all sorts of assertion testing. I don’t need that. I actually like just using the assert
module. Except one thing. The standard message for assert(false)
is useless.
I saw better-assert
, got excited, and then realized it only provided one method. All I wanted was the assert
module, with a better message.
So I made insist
. You can truly just drop it instead of assert
, and pretend it’s assert
. Also, unlike a few libraries who try to do this, insist
plays well with multi-line assertions.
var assert = require('insist');
var someArr = [15, 20, 5, 30];
assert(someArr.every(function(val) {
return val > 10;
}));
// output: AssertionError: assert(someArr.every(function(val) {
// return val > 10;
// }));
I insist.