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
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?
Most helpful comment
which version of mocha are you using? the retries are working fine, try this code snippet for example: