Skip to content

Commit 48a02c4

Browse files
authored
fix: no error thrown from rerun script (#4494)
* ENG-1059: Throw error * ENG-1059: Write tests * Revert changes to test for flakiness * Re-apply changes This reverts commit 6cba723.
1 parent d031ad0 commit 48a02c4

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

lib/command/run-rerun.js

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ module.exports = async function (test, options) {
1717
const testRoot = getTestRoot(configFile)
1818
createOutputDir(config, testRoot)
1919

20-
function processError(err) {
21-
printError(err)
22-
process.exit(1)
23-
}
2420
const codecept = new Codecept(config, options)
2521

2622
try {

lib/rerun.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class CodeceptRerunner extends BaseCodecept {
7070
await this.runTests(test);
7171
} catch (e) {
7272
output.error(e.stack);
73+
throw e;
7374
} finally {
7475
event.emit(event.all.result, this);
7576
event.emit(event.all.after, this);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
exports.config = {
2+
tests: './*_ftest.js',
3+
output: './output',
4+
helpers: {
5+
CustomHelper: {
6+
require: './customHelper.js',
7+
},
8+
},
9+
rerun: {
10+
minSuccess: 3,
11+
maxReruns: 3,
12+
},
13+
bootstrap: null,
14+
mocha: {},
15+
name: 'run-rerun',
16+
};

test/runner/run_rerun_test.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('run-rerun command', () => {
8383
)
8484
})
8585

86-
it('should display success run if test was fail one time of two attepmts and 3 reruns', (done) => {
86+
it('should display success run if test was fail one time of two attempts and 3 reruns', (done) => {
8787
exec(
8888
`FAIL_ATTEMPT=0 ${codecept_run_config('codecept.conf.fail_test.js', '@RunRerun - fail second test')} --debug`,
8989
(err, stdout) => {
@@ -96,4 +96,18 @@ describe('run-rerun command', () => {
9696
},
9797
)
9898
})
99+
100+
it('should throw exit code 1 if all tests were supposed to pass', (done) => {
101+
exec(
102+
`FAIL_ATTEMPT=0 ${codecept_run_config('codecept.conf.pass_all_test.js', '@RunRerun - fail second test')} --debug`,
103+
(err, stdout) => {
104+
expect(stdout).toContain('Process run 1 of max 3, success runs 1/3')
105+
expect(stdout).toContain('Fail run 2 of max 3, success runs 1/3')
106+
expect(stdout).toContain('Process run 3 of max 3, success runs 2/3')
107+
expect(stdout).toContain('Flaky tests detected!')
108+
expect(err.code).toBe(1)
109+
done()
110+
},
111+
)
112+
})
99113
})

0 commit comments

Comments
 (0)