Why does my jasmine test expire before DEFAULT_TIMEOUT_INTERVAL?

Related: Unable to set timeout for jasmine

Jasmine 2.4.1

My test reports a timeout failure, even if the timeout value is greater than the specified time.

I'm doing it:

 describe('tests content controller', function(){ beforeAll(function(done) { jasmine.DEFAULT_TIMEOUT_INTERVAL= 120000; //... }) fit('/content GET should return 200',function(done){ request(app) .get('/content') .set('Authorization', "bearer " + requestor.token) .set('Accept', 'application/json') .expect(200) .end(function (err, res) { console.log('timeout',jasmine.DEFAULT_TIMEOUT_INTERVAL); //prints 120000 if (err) done.fail(err); expect(res.statusCode).toBe(200); done(); }) }); 

Then this test fails:

 1) tests content controller /content GET should return 200 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) Finished in 106.449 seconds 

106.449 seconds is less than 120 seconds, which means my timeout value is set to.

So why does this test not work?

+5
source share
1 answer

I did not call done inside my beforeAll , which caused this error.

+2
source

Source: https://habr.com/ru/post/1240192/


All Articles