busterjs/buster — Issue #15: Async test cases in browser via RequireJS
Author: augustl
Created: 2011-12-08 16:02:24+00:00
State: open

Buster currently can't facilitate these types of tests:

require(["my/file"], function () {
buster.testCase("blah", {
// ....
});
});

The difficulty lies in knowing when all the buster.testCase functions have called. body.onload is not enough, due to the async require. Probably need some sort of counter to let buster know _before_ body.onload how many test cases that it expects to load.

Suggestion:

buster.asyncTestCase(function (testCase) {
require(["my/file"], function () {
testCase("My test case", {
// ....
});
});
});

With this model, buster knows at body.onload that there is one async test case that will be loaded in the future. It can wait for the passed "testCase" (which is just a wrapped buster.testCase) function to be called and know that if it isn't called it can timeout, and so on.