Mocha: Retry logic should accommodate a timeout between retries

Created on 18 May 2016  路  3Comments  路  Source: mochajs/mocha

this.retries(N); should support a timeout value before attempting to run the test again.

A signature like this.retries(N[, M]); where N is the # of retries & M is the # of ms to wait before trying the test again would be ideal

feature

Most helpful comment

I was able to use beforeEach to delay test execution in case of retries - in the following example we need to back off proportionally to the number of failures, but it can easily be a constant

describe(....

    // delay after first failure
    beforeEach(function(done){
      if(this.currentTest.currentRetry() > 0){
         setTimeout(done, this.currentTest.currentRetry() * 500);
      } else {
         done();
      }
   })
   this.retries(2)
  ...
  // test cases here 
  it( .... 

All 3 comments

This would be great for my end-to-end tests

yes this will be really helpful. Waiting for this to be implemented :)

I was able to use beforeEach to delay test execution in case of retries - in the following example we need to back off proportionally to the number of failures, but it can easily be a constant

describe(....

    // delay after first failure
    beforeEach(function(done){
      if(this.currentTest.currentRetry() > 0){
         setTimeout(done, this.currentTest.currentRetry() * 500);
      } else {
         done();
      }
   })
   this.retries(2)
  ...
  // test cases here 
  it( .... 
Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamhooper picture adamhooper  路  3Comments

robertherber picture robertherber  路  3Comments

daleharvey picture daleharvey  路  4Comments

danielserrao picture danielserrao  路  3Comments

luoxi001713 picture luoxi001713  路  3Comments