13. Testing

With all the code you have written so far, you’re now ready to look at how to test it to make sure it works. There are many models and paradigms through which this is done, and Node.js supports most of them. This chapter looks at some of the more common ones and then looks at how you can do functional testing of not only synchronous APIs but also Node’s asynchronous code and then add some testing to your photo album application.

Choosing a Framework

A few common models of testing are available, including test-driven development (TDD) and behavior-driven development (BDD). The former focuses highly on making sure that all your code is properly exposed to testing (indeed, in many cases, demanding that you write no code until you’ve ...

Get Learning Node.js, Second Edition 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.