Documentation

QUnit/asyncTest

From jQuery JavaScript Library

Jump to: navigation, search

« Back to QUnit

asyncTest( name, [expected], test )

Add an asynchronous test to run. The test must include a call to start().
Asynchronous tests added are queued and run one after the other. Equivalent to calling a normal test() and immediately calling stop().
Arguments:

nameString
The name of the test
expected (Optional)Number
How many assertions are expected to run.
testFunction
The actual testing code to run, should include at least one assertion.

Examples:
Add an async test that contains a single assertions that is always true.

asyncTest("a test", function() {
  setTimeout(function(){
    ok(true, "always fine");
    start();
  }, 13);
});

NameType