【发布时间】:2015-09-19 13:05:24
【问题描述】:
我有一个测试用例如下:
it("Should have a valid structure", function(done){
var data;
module(APP_MODULE_NAME);
inject(function(_metaService_){
metaService = _metaService_;
});
metaService.fetchEntityMeta('person').then(function(data){
expect(data.status).toBe( true );
done();
});
});
但我收到以下错误:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
我增加了 jasmine.DEFAULT_TIMEOUT_INTERVAL 但没有使用。 但是下面的代码确实有效。
setTimeout(function(){
expect(true).toBe(true);
done();
}, 5000);
所以,我的理解是我的承诺有问题。 我的问题是如何检查 promise 返回的数据。
【问题讨论】:
-
提供您的服务代码..
标签: angularjs unit-testing tdd jasmine karma-jasmine