For JavaScript developers working on increasingly large and complex projects, effective automated testing is crucial to success. Test-Driven JavaScript Development is a complete, best-practice guide to agile JavaScript testing and quality assurance with the test-driven development (TDD) methodology. Leading agile JavaScript developer Christian Johansen covers all aspects of applying state-of-the-art automated testing in JavaScript environments, walking readers through the entire development lifecycle, from project launch to application deployment, and beyond.
Using real-life examples driven by unit tests, Johansen shows how to use TDD to gain greater confidence in your code base, so you can fearlessly refactor and build more robust, maintainable, and reliable JavaScript code at lower cost. Throughout, he addresses crucial issues ranging from code design to performance optimization, offering realistic solutions for developers, QA specialists, and testers.
Coverage includes • Understanding automated testing and TDD • Building effective automated testing workflows • Testing code for both browsers and servers (using Node.js) • Using TDD to build cleaner APIs, better modularized code, and more robust software • Writing testable code • Using test stubs and mocks to test units in isolation • Continuously improving code through refactoring • Walking through the construction and automated testing of fully functional software
The accompanying Web site, tddjs.com, contains all of the book’s code listings and additional resources.
Giving a good insight into the flow of Test-Driven Development in JavaScript and other languages (it's a pretty easy concept to move around in different languages). The book is easy to read through and the author makes it fun to test out the ideas and concepts, not being afraid to let the reader test their TDD wings from early on (no worries, there's complete code to be downloaded if you want to learn it by the numbers). Finished reading it on Norways national day, funny when the book is written by an Norwegian! Loved the 1349 plug in the chat client code!
To me this book rectifies the things I did not like about Douglas Crockford's "Javascript: The Good Parts" (TGP). While TGP is just the kind of book I like - terse, to the point and about two hundred pages of quality content, the writing style is somewhat convoluted, it fails to present bigger working examples, it rarely discusses performance aspects, and it fails to mention any form of testing.
This book addresses all these, as well as being a far better tool for learning good javascript from the bottom up. Another good thing is that a good third of the book is dedicated to implementing a workable, useful, real-world MVP app written in vanilla js with full test coverage of all the layers.
This makes it a modern replacement for Crockford and one I keep picking up from time to learn or refresh a thing or two. Very much recommended!
The tools mentioned in the book for testing are somewhat antique by 2014, so one improvement could be a minor update where it included a more modern testing framework, such as Mocha or BusterJS.
First important point: Even though the first word in the book is test, this is primarily a book about development and not testing. Only the first section spent much time on testing frameworks (which is probably sensible, it doesn't take that long to explain how they work); the rest uses that as a base but isn't very test focused.
I'm personally not a believer in playing too many fancy games with javascript prototype chaining and closures - the complications, in my opinion, outweigh the benefits. The book does cover a lot of interesting material, but I think Crockford has written better introductions to the parts relating to JavaScript's particular quirks.