Mocha: --retries <number> doesn't work

Created on 26 Dec 2017  Â·  3Comments  Â·  Source: mochajs/mocha

I use following, case failed but doesn't retry, it there something wrong? Or I use the wrong way.
mocha --retries 2 casename.spec.js

question

Most helpful comment

which version of mocha are you using? the retries are working fine, try this code snippet for example:

let counter = 0;
describe('lol', function() {
  it('lols', function() {
    if(counter > 1) {
      console.log('counter::', counter) //logs 3
    } else {
      throw new Error(++counter)
    }
  })
})

All 3 comments

which version of mocha are you using? the retries are working fine, try this code snippet for example:

let counter = 0;
describe('lol', function() {
  it('lols', function() {
    if(counter > 1) {
      console.log('counter::', counter) //logs 3
    } else {
      throw new Error(++counter)
    }
  })
})

@Bamieh , thanks. I got it, it only retries the failed step, but I want to retry all the file:
my case likes that:
if the assert step fails, retry all steps, from step1 to asserts.

describe('lol', function() {
  it('step1', function() {});
  it('step2', function() {});
  it('step3', function() {});
  it('assert', function() {});
})

@luoxi001713 This sounds like a new feature and not a bug. However, js has looping. Is there a reason you don't want to add looping via the language itself or a task runner?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daleharvey picture daleharvey  Â·  4Comments

EdvinOlofsson picture EdvinOlofsson  Â·  3Comments

smithamax picture smithamax  Â·  4Comments

robertherber picture robertherber  Â·  3Comments

jamietre picture jamietre  Â·  3Comments