【发布时间】:2016-01-07 21:09:46
【问题描述】:
我已经尝试了this answer 中的所有解决方案,但没有一个对我有用。
我正在使用jasmine v2.3.2 和jasmine-core v2.3.4
当我做这个测试时:
jasmine.DEFAULT_TIMEOUT_INTERVAL= 999999;
describe('tests content controller', function(){
//...
fit('/content should return 200',function(done){
request(app)
.get('/content?type=script')
.set('Authorization', "bearer " + requestor.token)
.set('Accept', 'application/json')
.expect(200)
.end(function (err, res) {
if (err) done.fail(err);
expect(res.statusCode).toBe(200);
console.log('got here');
console.log(jasmine.DEFAULT_TIMEOUT_INTERVAL); //prints 30000
done();
})
},999999);
我在控制台上看到该请求只用了 3000 毫秒。我什至看到了我的got here 日志。
显示超时的日志打印出30000,而不是像我预期的那样打印出999999。
我也收到此测试失败的消息:
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
1 spec, 1 failure
Finished in 33.069 seconds
有一些初始设置会导致大约 30 秒的延迟。应用程序必须连接到多个数据库并运行describe 中的beforeAll 函数。
我怎样才能防止茉莉花像这样超时?
【问题讨论】:
-
jasmine.DEFAULT_TIMEOUT_INTERVAL应该在顶级代码上。您是否尝试将其放在任何describe之外? -
@just-boris 是的。我已经更新了我的代码以显示这一点
标签: javascript node.js jasmine