found drama

get oblique

review: Jasmine JavaScript Testing

by Rob Friesel

518JeRoUfjLPackt 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 testing1 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 code3 to MVC components4 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.

  1. 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. []
  2. Here I refer to Evan Hahn’s JavaScript Testing with Jasmine — not to confuse anyone over titles or anything. []
  3. Sinon.js FTW here. []
  4. He rather sensibly chose Backbone.js for these example. []
  5. Require.js being the AMD library-of-choice here. []

About Rob Friesel

Software engineer by day, science fiction writer by night. Author of The PhantomJS Cookbook and a short story in Please Do Not Remove. View all posts by Rob Friesel →

Leave a Reply

Your email address will not be published. Required fields are marked *