我越來越茉莉(http://pivotal.github.com/jasmine/)熟悉內部不上班,發現莫名其妙的東西:jasmine.js期待()異步回調
it("should be able to send a Ghost Request", function() {
var api = fm.api_wrapper;
api.sendGhostRequest(function(response) {
console.dir('server says: ', response);
});
expect(true).toEqual(false);
});
未能如預期。
然而,在移動期望回調內撥打:
it("should be able to send a Ghost Request", function() {
var api = fm.api_wrapper;
api.sendGhostRequest(function(response) {
console.dir('server says: ', response);
expect(true).toEqual(false);
});
});
不知何故傳遞:o
一些調試之後: api.sendGhostRequest()執行一個異步AJAX請求,和茉莉燈心草過去之前請求已完成。
因此,問題:
如何獲得茉莉花確定測試結果之前等待AJAX執行?
茉莉花2.0,你只需要調用它( 「降序」,函數(done){... done(); ...})。只是說,因爲這個線程是在谷歌結果高:) – pkopac 2016-04-12 13:33:31