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
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