Summary

This has definitely been a crash course on testing, but the groundwork has been laid and I hope that you have a solid understanding of the tool chain that you can use to write your own tests. We installed the Mocha test framework and wrote our first tests for Node.js. Using a custom testhelper.js file, we integrated the various libraries and frameworks necessary to write tests for our code. These tools included Chai.js to write our assertions and Sinon.js for our spies and stubs. Trust this powerhouse suite of tools and you'll be writing bulletproof code in no time!

The ultimate goal with writing tests is to have 100 percent complete code coverage and have unit tests exist for every line of code you write. From here, the true test is to ...

Get Web Development with MongoDB and Node.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.