Having trouble with jasmine 2 and getting async specs wired up:
define(['foo'], function(foo) {
return describe('foo', function() {
beforeEach(function(done) {
window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
return setTimeout((function() {
console.log('inside timeout');
return done();
}), window.jasmine.DEFAULT_TIMEOUT_INTERVAL);
});
return it('passes', function() {
return expect({}).toBeDefined();
});
});
});
When I run via karma, I get back
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
and then the specs fail. I have attempted to override the default timeout but I can't get past the error
My 2 Cents. I also got this error mentioned in the question in another scenario.
I had a very simple spec like this:
See the commented out //done() function in 'it'
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.
See fiddle here
Another option that might work for you is to use
async
See: https://angular.io/docs/ts/latest/guide/testing.html#!#async-in-before-each