Node.js Functional Testing with Mocha

In this blog post, Francois Zaninotto provides an detailed explanation on how to do functional testing for Node.js using the Mocha open source software testing framework. Mocha is a feature-rich JavaScript test framework running on node.js and the browser. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.

The explanation starts from a user story from which the acceptance criteria are discussed with the customer. The test are written following a Test-Driven approach. The post explains after how to setup and run the tests. Francois Zaninotto conclusion is that “Asynchronicity aside, writing functional tests in Node.js is quite simple. Using the assert module, mocha, and zombie.js, you should be able to implement most of the scenarios imagined by the product owner, and never do a manual browser test again.”