Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
test: case when retries count is below zero
Browse files Browse the repository at this point in the history
  • Loading branch information
eGavr committed Jun 30, 2017
1 parent deafd55 commit 0ff2467
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/unit/runner/suite-runner/insistent-suite-runner.js
Expand Up @@ -116,6 +116,18 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
});
});

it('should provide the ability to mutate the passed config', () => {
stubWrappedRun_((runner) => runner.emit(Events.ERROR, {state: makeStateStub()}));

const config = mkConfigStub_({retry: 1});
const runner = mkInsistentRunner_({config});

config.retry = 0;

return runner.run()
.then(() => assert.calledOnce(RegularSuiteRunner.prototype.run));
});

describe('run without retries', () => {
describe('on ERROR', () => {
it('should emit ERROR', () => {
Expand Down Expand Up @@ -248,6 +260,23 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
assert.calledOnce(RegularSuiteRunner.prototype.run);
});
});

it('should not retry if retries count is below zero', () => {
const onError = sinon.spy().named('onError');
const onRetry = sinon.spy().named('onRetry');

stubWrappedRun_((runner) => runner.emit(Events.ERROR, {state: makeStateStub()}));

return mkInsistentRunner_({config: mkConfigStub_({retry: -1})})
.on(Events.ERROR, onError)
.on(Events.RETRY, onRetry)
.run()
.then(() => {
assert.notCalled(onRetry);
assert.calledOnce(onError);
assert.calledOnce(RegularSuiteRunner.prototype.run);
});
});
});

describe('on TEST_RESULT without diff', () => {
Expand Down Expand Up @@ -343,6 +372,23 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
.run()
.catch(() => assert.calledOnce(RegularSuiteRunner.prototype.run));
});

it('should not retry if retries count is below zero', () => {
const onTestResult = sinon.spy().named('onTestResult');
const onRetry = sinon.spy().named('onRetry');

stubWrappedRun_((runner) => runner.emit(Events.TEST_RESULT, {equal: false, state: makeStateStub()}));

return mkInsistentRunner_({config: mkConfigStub_({retry: -1})})
.on(Events.TEST_RESULT, onTestResult)
.on(Events.RETRY, onRetry)
.run()
.then(() => {
assert.notCalled(onRetry);
assert.calledOnce(onTestResult);
assert.calledOnce(RegularSuiteRunner.prototype.run);
});
});
});

it('should retry only failed states', () => {
Expand Down

0 comments on commit 0ff2467

Please sign in to comment.