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

Commit

Permalink
fix: child suite retries not called
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy-kiselyov committed Feb 26, 2018
1 parent 8461ac5 commit 6268b62
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/runner/suite-runner/insistent-suite-runner.js
Expand Up @@ -13,7 +13,7 @@ module.exports = class InsistentSuiteRunner extends SuiteRunner {
}

constructor(suite, browserAgent, config) {
super(suite, browserAgent);
super(suite.clone(), browserAgent);

this._config = config;
this._retriesPerformed = 0;
Expand Down
36 changes: 32 additions & 4 deletions test/unit/runner/suite-runner/insistent-suite-runner.js
Expand Up @@ -45,18 +45,31 @@ describe('runner/suite-runner/insistent-suite-runner', () => {

afterEach(() => sandbox.restore());

it('should create regular suite runner', () => {
it('should clone suite on creation', () => {
const suite = makeSuiteStub();
const browserAgent = mkBrowserAgentStub_();
const config = mkConfigStub_();

sandbox.spy(suite, 'clone');
const runner = InsistentSuiteRunner.create(suite, browserAgent, config);

assert.calledOnce(suite.clone);
assert.notEqual(suite, runner._suite);
});

it('should create regular suite runner and pass cloned suite', () => {
const suite = makeSuiteStub();
const browserAgent = mkBrowserAgentStub_('bro');
const config = mkConfigStub_();

sandbox.spy(RegularSuiteRunner, 'create');

return InsistentSuiteRunner.create(suite, browserAgent, config)
.run()
.then(() => {
assert.calledOnce(RegularSuiteRunner.create);
assert.calledWith(RegularSuiteRunner.create, suite, browserAgent);
assert.notEqual(RegularSuiteRunner.create.getCall(0).args[0], suite);
});
});

Expand Down Expand Up @@ -208,9 +221,9 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
assert.notCalled(onError);

assert.calledOnce(onRetry);
assert.calledWith(onRetry, {
assert.calledWithMatch(onRetry, {
foo: 'bar',
suite,
suite: _.omit(suite, 'browsers'),
state,
browserId: 'bro',
attempt: 0,
Expand All @@ -228,6 +241,21 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
.then(() => assert.callCount(RegularSuiteRunner.prototype.run, 1 + 2));
});

it('should not modify original suite', () => {
const suite = makeSuiteStub();
const state = makeStateStub(suite);
const browserAgent = mkBrowserAgentStub_();
stubWrappedRun_((runner) => runner.emit(Events.ERROR, {state}));
const config = mkConfigStub_({retry: 1});

sandbox.spy(RegularSuiteRunner, 'create');
const suiteBefore = suite.clone();

return mkInsistentRunner_({suite, browserAgent, config})
.run()
.then(() => assert.deepEqual(suite, suiteBefore));
});

it('should count few errors during run for one', () => {
const state = makeStateStub();

Expand Down Expand Up @@ -328,7 +356,7 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
assert.calledOnce(onRetry);
assert.calledWithMatch(onRetry, {
equal: false,
suite,
suite: _.omit(suite, 'browsers'),
state,
browserId: 'bro',
attempt: 0,
Expand Down

0 comments on commit 6268b62

Please sign in to comment.