1
私はジャスミンのようなテストのためにデータセットをロードしようとしています... しかし、そのjsonコールとして私は傾けるように見えるいつもによって示されるテストを得る配列を使用する前にJSON呼び出しが終了するまで待つ必要があります。私は無駄にajaxStop関数を使用してみました。何か案は ?代わりに$ .getJSONを使用してのユニットテストでJSONのJavery ajaxのロード
describe("simple checks", function() {
var exampleArray = new Array();
beforeEach(function(){
$(document).ajaxStop(function() {
$(this).unbind("ajaxStop");
$.getJSON('/jasmine/obj.json', function(data) {
$.each(json.jsonattr, function(i, widgetElement) {
exampleArray.push(new widget(widgetElement));
});
});
});
});
it("use the exampleArray", function() {
doSomething(exampleArray[0]); // frequently this is coming up as undefined
});
jqueryrocks最も確かにロックmerci beaucoupをあなたに! – wmitchell