I’ve recently spent quite a bit of time working with QUnit, a great unit testing framework for Javascript. While building out a larger test suite, I ran into a few issues, especially while testing/working with dependency managers and the QUnit test framework. In this post I’ll document some of the issues I ran into, some patterns I started using, and a few tricks I used to ensure consistent and reliable test results. The main issues I ran into were caused by the fact that I was testing modules that were being loaded asynchronously. This meant that in some cases QUnit would miss tests, misplace module labels, and/or report false positives. Now when I mention async here, it is not to be confused with QUnit’s native support for asyncTests.

Problem #1: QUnit.done misfiring

QUnit.done = function(qunitReport) {
  console.log('Done!');
};
setTimeout(function() {
  test("helloworld", function() {
    expect( 1 );
    ok(true);
  });
}, 100);

Read the rest of this entry »

Advertisements