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, mochachai and karma.

Comments

Popular posts from this blog

What is a Callback function in Node.js?

What is an Event loop in Node.js and how does it work?