How to test your code in Node.js?
The assert
module in Node.js provides easy way of writing test in a limited ways. It provides no feedback when running your tests unless one fails. It provides 11 methods to test our code to check it is working as we expect. Some of them are: assert.equal
, assert.deepEqual
, assert.throws
.
assert.equal(2 + 2, 4, 'two plus two is four');
Other than this, we can use testing frameworks like, mocha
, chai
and karma
.
Comments
Post a Comment