Recommended Reading: Test-Driven JavaScript Development

Test-driven development can be a tricky thing to master and, depending on what language you prefer to code in, resources on the topic can be lacking. For JavaScript developers, however, there’s help. Christian Johansen’s book Test-Driven JavaScript Development is a solid guide to getting started with TDD in JavaScript.

One of the things I really liked about this book was its scope. Unlike a lot of programming books that focus on a single tool or only on the code, Johansen does a great job of guiding the reader through the concept of test-driven development from multiple angles. The way the book is structured makes test-driven development feel like less like a buzzword and more like a logical design choice. He even goes as far as to explain some of the pitfalls of TDD:

Writing unit tests is not always easy. In particular, writing good unit tests takes practice, and can be challenging. The benefits listed in Section 1.5, Benefits of Unit Tests all assume that unit tests are implemented following best practices. If you write bad unit tests, you might find that you gain none of the benefits, and instead are stuck with a bunch of tests that are time-consuming and hard to maintain. In order to write truly great unit tests, the code you’re testing needs to be testable. If you ever find yourself retrofitting a test suite onto an existing application that was not written with testing in mind, you’ll invariably discover that parts of the application will be challenging, if not impossible, to test. As it turns out, testing units in isolation helps expose too tightly coupled code and promotes separation of concerns. Throughout this book I will show you, through examples, characteristics of testable code and good unit tests that allow you to harness the benefits of unit testing and test-driven development.


Johansen, Christian (2010-09-09). Test-Driven JavaScript Development (Developer’s Library) (Kindle Locations 840-847). Pearson Education (US). Kindle Edition.

If you’ve ever been curious about TDD in JavaScript, this is definitely a book you’ll want to pick up. You can snag a copy over at Amazon