2016-01-08 10 views
5

correlati: Can't set timeout for jasminePerché il test del mio gelsomino è scaduto prima del DEFAULT_TIMEOUT_INTERVAL?

Jasmine 2.4.1

Il mio test segnala un fallimento a causa di timeout, anche se il valore di timeout sembra essere maggiore del tempo riportato.

sto facendo questo:

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(); 
     }) 
    }); 

Allora questo test non riesce, con:

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 secondi è inferiore a 120 secondi, che è ciò che il mio valore di timeout sembra essere impostato su .

Quindi, perché questo test fallisce?

+1

@engineer che esegue il metodo 'getEnv()' causa il 'console.log' che stampa il timeout per non essere colpito. Cambiare 'beforeAll' su' beforeEach' non è stato d'aiuto – Houseman

risposta

2

Non stavo chiamando done all'interno del mio beforeAll, che ha causato questo errore.

Problemi correlati