Я мог бы это выяснить, но я собираюсь использовать SO. В моих модульных тестах (qunit) я использую тест asynchShould
(псевдоним для asynchTest). Часть утверждения состоит в том, чтобы ждать завершения / успеха запроса. Как это:
asyncShould('talk to customer list server', 1, function() {
stop(2000);
var forCustomerList = newCustomerListRequest();
forCustomerList.page = 'helpers/helper.php';
forCustomerList.data += '&action=customerListServer&DB=11001';
var originalSuccess = forCustomerList.success;
forCustomerList.success = function(msg) {
if (msg.flash !== undefined && msg.data !== undefined && msg.status !== undefined) {
ok(true, 'json structure correct')
}
else {
ok(false, 'json structure not correct');
}
originalSuccess(msg);
start();
};
testController.getServerData(forCustomerList);
})