2016-01-08 16 views
5

liên quan: Can't set timeout for jasmineTại sao thời gian thử nghiệm hoa nhài của tôi hết trước DEFAULT_TIMEOUT_INTERVAL?

Jasmine 2.4.1

thử nghiệm của tôi báo cáo một thất bại do thời gian chờ, mặc dù giá trị timeout dường như là lớn hơn thời gian báo cáo.

tôi đang làm điều này:

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

Sau đó, thử nghiệm này không thành công, với:

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 giây là ít hơn 120 giây, đó là những gì giá trị timeout của tôi dường như được thiết lập để .

Vậy tại sao thử nghiệm này lại thất bại?

+1

@engineer làm phương thức 'getEnv()' gây ra 'console.log' để in thời gian chờ không bị tấn công. Thay đổi 'beforeAll' thành' beforeEach' không giúp được gì – Houseman

Trả lời

2

Tôi không gọi số done bên trong số beforeAll, lỗi này gây ra lỗi này.

Các vấn đề liên quan