Previous month:
February 2012
Next month:
September 2012

August 2012

Better Continuous Testing in JavaScript

Things have come a long way since I wrote Continuous Testing in Ruby, Rails, and JavaScript. Lately, for JavaScript, I've been using John Bintz's jasmine-headless-webkit and his complementary guard plugin.

This tool has some really awesome features, not the least of which is that the environment your tests run in is really webkit. That means that you don't have to mock out major parts of the browser environment like window.location, localStorage and sessionStorage, and XMLHttpRequest if you don't want to.

Another great feature is the ability to generate an html file that will run all your tests in a real browser, whenever guard runs tests. Combined with the Live Page plugin for chrome, I get instant feedback about whether or not my Jasmine tests actually pass in the browser.

However, there is one downside compared the node.js technique I outlined in my book. jasmine-headless-webkit doesn't give you real stack traces in the guard output when tests fail. Usually this means you resort to looking at the test failure in the browser (using that generated html file). In practice, it's not a big deal, but it also means you need to make sure your tests pass in both environments, otherwise you might be stuck with a failing test that you can't diagnose.