Skip to content

Commit 0b3a5b7

Browse files
committed
test: add regression tests for retry config accumulation
1 parent 34ba60f commit 0b3a5b7

6 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export const config = {
2+
tests: './retry_accumulation_test.js',
3+
output: './output',
4+
helpers: {
5+
Playwright: {
6+
url: 'http://localhost:8000',
7+
manualStart: true,
8+
},
9+
AccumulationHelper: {
10+
require: './helper.accumulation.js',
11+
},
12+
},
13+
plugins: {
14+
retryFailedStep: {
15+
enabled: true,
16+
retries: 2,
17+
},
18+
},
19+
bootstrap: null,
20+
mocha: {},
21+
name: 'retryAccumulation',
22+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const config = {
2+
tests: './retry_multiple_scenarios_test.js',
3+
output: './output',
4+
helpers: {
5+
Playwright: {
6+
url: 'http://localhost:8000',
7+
show: false,
8+
restart: false,
9+
},
10+
AccumulationHelper: {
11+
require: './helper.accumulation.js',
12+
},
13+
},
14+
plugins: {
15+
retryFailedStep: {
16+
enabled: true,
17+
retries: 2,
18+
},
19+
},
20+
bootstrap: null,
21+
mocha: {},
22+
name: 'retryMultipleScenarios',
23+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Helper from '../../../../../lib/helper.js';
2+
3+
class AccumulationHelper extends Helper {
4+
_before() {
5+
this._failCount = 0;
6+
}
7+
8+
failingStep() {
9+
this._failCount++;
10+
if (this._failCount <= 2) {
11+
throw new Error('failing step - retry expected');
12+
}
13+
}
14+
}
15+
16+
export default AccumulationHelper;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature('Retry Config Accumulation Test');
2+
3+
Scenario('first scenario', async ({ I }) => {
4+
I.failingStep();
5+
});
6+
7+
Scenario('second scenario', async ({ I }) => {
8+
I.failingStep();
9+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature('Retry FailedStep - Multiple Consequent Scenarios');
2+
3+
Scenario('first scenario', async ({ I }) => {
4+
I.failingStep();
5+
});
6+
7+
Scenario('second scenario', async ({ I }) => {
8+
I.failingStep();
9+
});
10+
11+
Scenario('third scenario', async ({ I }) => {
12+
I.failingStep();
13+
});

test/runner/retry_hooks_test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,20 @@ describe('CodeceptJS Retry Hooks', function () {
6666
done()
6767
})
6868
})
69+
70+
it('should prevent retry config accumulation across tests', done => {
71+
exec(config_run_config('codecept.retry.accumulation.conf.js', ''), (err, stdout) => {
72+
debug_this_test && console.log(stdout)
73+
expect(stdout).toContain('2 passed')
74+
done()
75+
})
76+
})
77+
78+
it('should retryFailedStep on multiple consequent scenarios', done => {
79+
exec(config_run_config('codecept.retry.multipleScenarios.conf.js', ''), (err, stdout) => {
80+
debug_this_test && console.log(stdout)
81+
expect(stdout).toContain('3 passed')
82+
done()
83+
})
84+
})
6985
})

0 commit comments

Comments
 (0)