我已经尝试了所有解决方案这个答案 https://stackoverflow.com/questions/9867601/how-do-i-change-the-timeout-on-a-jasmine-node-async-spec但他们都不适合我。
我在用着jasmine v2.3.2
and 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
log.
打印出显示超时的日志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 秒的延迟。该应用程序必须连接到多个数据库并运行beforeAll
函数在describe
.
我怎样才能防止茉莉花这样超时?