Test-Driven JavaScript Development by Christian Johansen – book review

Test-Driven JavaScript Development

Test-Driven JavaScript Development Front Cover

This post is my first attempt to write a book review. Let’s start with my newest book: Test-Driven JavaScript Development written by Christian Johansen. As the back cover says, Test-Driven JavaScript Development is a complete, best-practice guide to agile JavaScript testing and quality assurance with the test-driven development (TDD) methodology.

At the beginning I would like to say big thanks to the author – Christian who gave me the book at the Front-Trends 2010 Conference. The book is brand new (first printing, September 2010), so I’m more excited to have it right now. Thank You Christian 🙂

Who the author is?

Christian Johansen has spent his professional career specializing in web and front-end development with technologies such as JavaScript, CSS, and HTML using agile practices. A frequent open source contributor, he blogs about JavaScript, Ruby, and web development at cjohansen.no. Christian works at Shortcut, a Norwegian software company focusing on open technology, web applications and mobile applications.

Leaving coding in “the cowboy style” he tried to improve code quality, confidence. He has spent a lot of time investigating unit testing and TDD in JavaScript.

He lives in Oslo, Norway.

What this book is about?

Automated testing provides a solution to the manual testing process. It’s easier, faster to do test automatically than by hand. Test-driven development is a step further. It moves unit tests to the front row, making them the primary point. In TDD tests are written before writing production code.

The book is organized in 4 parts. Each part can be read in other than suggested order. Generally the book is about programming in JavaScript for the real world using the Test-Driven Development approach. This is not just codding style, it’s the confidence in your code because the test coverage, the ability to fearlessly refactor code. It’s about writing modular code that can be easily tested.

  1. Test-Driven Development
  2. JavaScript for Programmers
  3. Real-World Test-Driven Development in JavaScript
  4. Testing Patterns

Part I. Test-Driven Development

First part is the introduce into the concept of automated JavaScript tests. Author explains it from basic unit tests (what it is, what it does, what it’s good for), then extending the basic tests, he introduce the test-driven development idea. The transition from automated tests into TDD is smooth and natural. At the end of this part Johansen shows a few unit testing frameworks, describes them and choose one of them, which will be used at the most throughout the book.

Part II. JavaScript for Programmers

Second part is concentrated at deeper look at JavaScript programming. It can be named as a complete introduction into JavaScript language. This part is for both beginners and advanced js coders. It helps understand where JavaScript differs from other languages (if you got used to one) and give the foundation needed for the real-word scenarios described in next part. Programmers who are really ninjas in js (knows closures, prototypal inheritance, dynamics of this may want to skip this part – but IMHO it’s good reminder.

Part III. Real-World Test-Driven Development in JavaScript

This is the main part of the book. You can find there information about developing process of small general purpose JavaScript API, DOM dependent widget, abstract browser differences, implementing a server-side JavaScript application, everything using test-driven development. The third part is focused on how test-driven development can help in building API’s and modularized code.

This part is based on small projects. Each of them introduces new test-related concepts and shows them in practice. Code supplied in this part is runnable and actually does things. From this part reader can learn how to test code that depends on browser API, timers, event handlers, DOM manipulation, asynchronous requests, etc. Also ides on how to extend the functionality are offered. Extended solutions are available from the books website.

As the result of the Real-World Test-Driven Development part is a fully functional instant messaging chat client and server, written using TDD and nothing but JavaScript.

Part IV. Testing Patterns

The last, final part of the book reviews some of the techniques used throughout previous part, but from a wider angle. Tests are investigated much detailed way with different forms of test verification. At the end, author gives some guidelines to help write good unit tests.


This book is for people who haven’t got any previous knowledge of unit testing or test-driven development. TDD approach is present through the whole book, so it provides strong understanding of the idea. This book is useful even for those who are not JavaScript experts – the second part gives strong bases in this subject. Every chapter is finished with summary which helps to gather all the most important information.

Test-Driven JavaScript Development is a complete, best-practice guide to JavaScript testing. It covers all aspects of applying automated tests in JavaScript environments, the entire development lifecycle. Christian is using real-life examples driven by unit tests, shows the test-driven development (TDD) principles. I remember his real-life coding at Front-Trends 2010, there is a much more in this book. Using that approach you can build more maintainable, and reliable JavaScript code.

The book’s website (http://tddjs.com) contains code listings (zip archives and git repositories). For the Part III the Git repositories can be especially useful because they navigate the history, shows how the code evolved, allows you to see each step taken.

Technical details

Title: Test-Driven JavaScript Development (Developer’s Library)
Author: Christian Johansen
ISBN-13: 978-0-321-68391-5
ISBN-10: 0-321-68391-9
Copyright © 2011 Pearson Eduction, Inc.
Where to buy? Amazon – book, InformIt – PDF


Przeczytaj także

Komentarze: 2

Dodaj komentarz »

Marcin Kłeczek

Bardzo dobry opis książki – widziałem ją pobieżnie, ale nie byłem do końca zdecydowany (JS nie jest moim podstawowym językiem). Teraz jak ją zobaczę, to kupię. Dzięki.




Thanks a lot for the thorough review, Robert. It appears that you’ve gotten everything out of this book that I had hoped to convey 🙂




Dodaj komentarz

(nie będzie publikowany)

Dozwolone tagi XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© 2009 - 2016 Vokiel.com
WordPress Theme by Arcsin modified by Vokiel