Jasmine: Async Callback Was Not Invoked Within Timeout Specified by Jasmine.Default_Timeout_Interval

Error: Timeout - Async callback was not invoked within 5000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)

The problem is that you need to ensure that the test is finished according to jasmine standards. The easiest way to do this is to use a done parameter. It would be like this:

describe("test function",funtion(){
it("testing",done => {
test().then(function(data,err){
console.log("resolved Data = ",data)
expect(data).toEqual({id:1}))
done();
}))
})
})

You just need to make sure that done() is invoked when the test is finished.

I am getting Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL Error

Increase the jasmin default time interval. You add below code to conf.js file.

Code:

    jasmineNodeOpts: {
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 1440000
}

jasmine 2 - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL

You are using the same timeout interval as Jasmine is using to fail tests on timeout, i.e. your timeout is triggered to fire with Jasmine's default interval, which fails the test.

If you set your timeout to be less than jasmine default timeout the test passes.

describe('foo', function () {
beforeEach(function (done) {
window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
setTimeout(function () {
console.log('inside timeout');
done();
}, 500);
});
it('passes', function () {
expect({}).toBeDefined();
});
});

See fiddle here



Related Topics



Leave a reply



Submit