review: Jasmine JavaScript Testing
¶ by Rob FrieselPackt Publishing recently released Jasmine JavaScript Testing by Paulo Ragonha (@pirelenito), and I just wrapped up reading it this morning. I’ve read a few books on JavaScript unit testing 1 and at least one other that was dedicated to Jasmine, 2 and this one is a strong entry.
If you’re unfamiliar with Jasmine, Ragonha will give you a solid foundation of the testing framework by the end of the second chapter. Less than 40 pages in and you’ll understand Jasmine’s approach to testing, as well as how to stand up a basic test suite. His coverage of the core functions and the collection of built-in matchers is concise and accurate. He builds on this foundation by demonstrating Jasmine’s abilities in testing everything from asynchronous code 3 to MVC components 4 to AMD modules. 5
Despite the title, Jasmine JavaScript Testing isn’t merely about the testing framework, or even just about testing. What Ragonha gives us is a book about how to write better code, using testability as the measurement of success. What is strongest about this book is how he uses a refactoring project as a frame-of-reference for telling the testability story. He’s not just talking about using Jasmine for writing tests; he’s talking about how to use it alongside the other tools and patterns that will make you a better front-end developer.
If you’re just getting started with testing JavaScript for the front-end, or if you want to see some good real-world examples, then I would definitely recommend this one.
Disclosure: I received an electronic copy of this book from the publisher in exchange for writing this review.
- There was Mark Ethan Trostler’s Testable JavaScript; and then there’s Nicholas Zakas’ Maintainable JavaScript which, while not technically about testing, has at least the one chapter about it.[↩]
- Here I refer to Evan Hahn’s JavaScript Testing with Jasmine — not to confuse anyone over titles or anything.[↩]
- Sinon.js FTW here.[↩]
- He rather sensibly chose Backbone.js for these example.[↩]
- Require.js being the AMD library-of-choice here.[↩]
Leave a Reply