【发布时间】:2016-08-03 22:54:32
【问题描述】:
有人可以帮我理解为什么这不起作用吗?我正在使用 Jasmine 的 both 函数来等待 promise.then 函数也被调用并做出断言。但它在被调用之前就超时了。
describe('greeting', function(){
var greeting = 'hello';
it('should call promise.then', function(done) {
inject(function ($q) {
var deferred = $q.defer();
deferred.resolve(greeting);
deferred.promise.then(function (greeting) {
expect(greeting).toEqual('hello');
done();
});
});
});
});
then 函数未被调用,Jasmine 超时并显示以下消息:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
【问题讨论】:
标签: angularjs asynchronous jasmine