Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Run asynchronous qunit test serially
test( 'async tests', function() {
// My custom async function
function ajax(data, successCallback) {
$.ajax({
url: 'server.php',
data: data,
success: successCallback,
error: function( xhr, textStatus ){
ok( false, textStatus );
}
});
};
// Run next test in tests array, or start().
function next(){
var test = tests.shift();
test ? test() : start();
};
// Tests to run, in order.
var tests = [
function(){
ajax({ foo: 1 }, function(){
ok(true);
next();
});
},
function(){
ajax({ bar: 2 }, function(){
ok(true);
next();
});
},
function(){
ajax({ baz: 3 }, function(){
ok(true);
next();
});
},
];
stop();
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.