I've tried all the solutions in this answer but none of them work for me.
我已经尝试了这个答案中的所有解决方案,但它们都不适合我。
I'm using jasmine v2.3.2
and jasmine-core v2.3.4
我正在使用jasmine v2.3.2和jasmine-core v2.3.4
When I do this test:
当我做这个测试时:
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);
I see on my console that the request took only 3000 milliseconds. I even see my got here
log.
我在控制台上看到请求只花了3000毫秒。我甚至看到我在这里登录。
The log that shows the timeout prints out 30000
and not 999999
like I expect.
显示超时的日志打印出30000而不是我期望的999999。
I also get a failure for this test with the message:
我也通过以下消息对此测试失败:
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
There is some initial setup which causes the majority of this ~30 second delay. The application has to connect to several databases and run the beforeAll
function in the describe
.
有一些初始设置导致大部分~30秒延迟。应用程序必须连接到多个数据库并在describe中运行beforeAll函数。
How can I get prevent jasmine from timing out like this?
我怎样才能防止茉莉花这样的超时?
1 个解决方案
#1
6
Try setting the jasmine.DEFAULT_TIMEOUT_INTERVAL
in a beforeAll
, since the timeout interval is reset for each it
block:
尝试在beforeAll中设置jasmine.DEFAULT_TIMEOUT_INTERVAL,因为为每个块重置了超时间隔:
describe("testing timeout", function() {
beforeAll(function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 999999;
});
fit('should have custom timeout', function(){
console.log(jasmine.DEFAULT_TIMEOUT_INTERVAL); //prints 999999
});
})
Also, keep in mind that setTimeout is using a 32 bit integer to store the delay behind the scenes, so integer values that exceed this will cause overflow. See this post: Infinite jasmine timeout
另外,请记住setTimeout使用32位整数来存储幕后延迟,因此超过此值的整数值将导致溢出。看这篇文章:无限茉莉花超时
#1
6
Try setting the jasmine.DEFAULT_TIMEOUT_INTERVAL
in a beforeAll
, since the timeout interval is reset for each it
block:
尝试在beforeAll中设置jasmine.DEFAULT_TIMEOUT_INTERVAL,因为为每个块重置了超时间隔:
describe("testing timeout", function() {
beforeAll(function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 999999;
});
fit('should have custom timeout', function(){
console.log(jasmine.DEFAULT_TIMEOUT_INTERVAL); //prints 999999
});
})
Also, keep in mind that setTimeout is using a 32 bit integer to store the delay behind the scenes, so integer values that exceed this will cause overflow. See this post: Infinite jasmine timeout
另外,请记住setTimeout使用32位整数来存储幕后延迟,因此超过此值的整数值将导致溢出。看这篇文章:无限茉莉花超时