Wrapping Up

Automated tests give us the benefit of regression. Writing those tests alongside writing the code, instead of after, has an added benefit—it can help shape the design. For a piece of code to be verified automatically, it has to be modular, cohesive, and decoupled.

In this chapter we dipped our toes into test-driven design. You learned to use Mocha, Chai, Karma, and Istanbul to write tests, run them, and keep an eye on the coverage. We used the same set of tools to write tests for both server- and client-side code. The tests were not really different—the main difference was in how we brought in the functions being tested. That will change when we start doing server-side and client-side specific coding.

Testing methods that take ...

Get Test-Driving JavaScript Applications 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.