Sunday, April 14, 2013

Node.js testing with Mocha and should.js

I noticed that i was doing a lot of exploratory testing in node.js. I wanted to checkout how easy/difficult would it be TDD. This is what i found. There is a decent testing framework called Mocha.

Testing node.js modules with Mocha Following is the module under test, which is just there as a test really. My barebones math class is below.

Following are the tests for the MyMath module. Neat and simple. I have used the should module to do the assertions.

Finally, this is how you can run the tests using mocha.


 

To install Mocha and should you could use the Node package manager.To read further please head to Mocha

No comments:

Post a Comment

Followers

About Me

I'm a software developer with interests in Design Patterns, Distributed programming, Big Data, Machine Learning and anything which excites me. I like to prototype new ideas and always on the lookout for tools which help me get the job done faster. Currently, i'm loving node.js + Mongodb.