Difference between setting "defaultTimeoutInterval: 2500000" in config file AND setTimeout function in 'beforeEach' with callbacks to done in its

1,657 views
Skip to first unread message

Suswari Reddy

unread,
Apr 13, 2017, 2:53:46 PM4/13/17
to Jasmine
Hi,
I am actually confused and wanted to know the how jasmine works with two scenarios as below.
This all raised as I was experiencing an Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL

scenario 1) 
To solve the above error I tried adding setTimeout function to beforeEach like:
beforeEach(function(done) {
setTimeout(function() {
value = 0;
done();
}, 6000);
}) 

it('User creates a new SAP', function (done) {
value++;
expect(value).toBeGreaterThan(0);
//some code
    //some code
    //some code
done();
});

And the error was not resolved.

scenario 2).
Instead I added to my config file like:
jasmineNodeOpts : {
defaultTimeoutInterval: 2500000
},

which resolved the error.


So my question is, how jasmine considers both the scenarios and why did not scenario 1 work?

Tony Brix

unread,
Apr 13, 2017, 4:37:18 PM4/13/17
to Jasmine
https://jasmine.github.io/2.5/introduction.html#section-Asynchronous_Support

by default defaultTimeoutInterval is set to 5000 so if an async operation takes longer than 5 seconds jasmine will throw that error.

setting defaultTimeoutInterval to 2500000 tells jasmine to wait about 42 minutes for the async operation to finish
Reply all
Reply to author
Forward
0 new messages