0
Jasmine新手,我正在測試一個async
函數。它顯示錯誤說Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
如果我在這裏失去了一些東西,請幫忙。Jasmine異步錯誤:超時 - 在jasmine.DEFAULT_TIMEOUT_INTERVAL指定的超時內未調用異步回調
功能進行測試:
function AdressBook(){
this.contacts = [];
this.initialComplete = false;
}
AdressBook.prototype.initialContact = function(name){
var self = this;
fetch('ex.json').then(function(){
self.initialComplete = true;
console.log('do something');
});
}
測試規格是如下:
var addressBook = new AdressBook();
beforeEach(function(done){
addressBook.initialContact(function(){
done();
});
});
it('should get the init contacts',function(done){
expect(addressBook.initialComplete).toBe(true);
done();
});