Passing along arguments to QUnit tests

Passing along arguments to QUnit tests

Hi - I just discovered QUnit.

When using it, I noticed that the 'test()' function doesn't provide a simple way to pass along arguments to the test function. This makes it prone to errors in which the wrong variables are captured in the test function's closure.

For instance:

var tests = [ test1, test2, test3 ];
for (var i = 0; i < tests.length; i++) {
    var test = tests[i];
    test("...", function () {
         stop();
         $.getJSON(...., function () {
               equals(test.someprop, ....)
               start();
         }
    });
}

will of course fail. Fixing it would require moving the call to test into an anonymous or named function.

What is the rationale for not allowing either arguments to be passed along, as in 'test(msg, func, arg1, arg2, arg3, ...)' or supporting a test object that has a 'test' method and may carry additional data, as in 'test(msg, { 'test': function () { ... }, .... })'?

It seems to me both features could be added in a backwards-compatible way; I'm sure this must have been considered before - why was it discarded?

Thanks!

 - Godmar