From bd730fe5e4d88251f3e6d4688a1079181f5697ec Mon Sep 17 00:00:00 2001 From: Brian Lin Date: Fri, 13 Sep 2024 20:09:20 +0000 Subject: [PATCH 1/2] ENG-1059: Throw error --- lib/command/run-rerun.js | 4 ---- lib/rerun.js | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/command/run-rerun.js b/lib/command/run-rerun.js index 62f17bdae..ccb18bcfd 100644 --- a/lib/command/run-rerun.js +++ b/lib/command/run-rerun.js @@ -17,10 +17,6 @@ module.exports = async function (test, options) { const testRoot = getTestRoot(configFile) createOutputDir(config, testRoot) - function processError(err) { - printError(err) - process.exit(1) - } const codecept = new Codecept(config, options) try { diff --git a/lib/rerun.js b/lib/rerun.js index b39b0b62e..df4549209 100644 --- a/lib/rerun.js +++ b/lib/rerun.js @@ -70,6 +70,7 @@ class CodeceptRerunner extends BaseCodecept { await this.runTests(test); } catch (e) { output.error(e.stack); + throw e; } finally { event.emit(event.all.result, this); event.emit(event.all.after, this); From 635e628b7e529b9509aedb2af026def91bc7ab3c Mon Sep 17 00:00:00 2001 From: Brian Lin Date: Fri, 13 Sep 2024 20:38:08 +0000 Subject: [PATCH 2/2] ENG-1059: Write tests --- .../run-rerun/codecept.conf.pass_all_test.js | 16 ++++++++++++++++ test/runner/run_rerun_test.js | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/data/sandbox/configs/run-rerun/codecept.conf.pass_all_test.js diff --git a/test/data/sandbox/configs/run-rerun/codecept.conf.pass_all_test.js b/test/data/sandbox/configs/run-rerun/codecept.conf.pass_all_test.js new file mode 100644 index 000000000..3c2ef30d8 --- /dev/null +++ b/test/data/sandbox/configs/run-rerun/codecept.conf.pass_all_test.js @@ -0,0 +1,16 @@ +exports.config = { + tests: './*_ftest.js', + output: './output', + helpers: { + CustomHelper: { + require: './customHelper.js', + }, + }, + rerun: { + minSuccess: 3, + maxReruns: 3, + }, + bootstrap: null, + mocha: {}, + name: 'run-rerun', +}; diff --git a/test/runner/run_rerun_test.js b/test/runner/run_rerun_test.js index 75511583a..a38ba54af 100644 --- a/test/runner/run_rerun_test.js +++ b/test/runner/run_rerun_test.js @@ -83,7 +83,7 @@ describe('run-rerun command', () => { ) }) - it('should display success run if test was fail one time of two attepmts and 3 reruns', (done) => { + it('should display success run if test was fail one time of two attempts and 3 reruns', (done) => { exec( `FAIL_ATTEMPT=0 ${codecept_run_config('codecept.conf.fail_test.js', '@RunRerun - fail second test')} --debug`, (err, stdout) => { @@ -96,4 +96,18 @@ describe('run-rerun command', () => { }, ) }) + + it('should throw exit code 1 if all tests were supposed to pass', (done) => { + exec( + `FAIL_ATTEMPT=0 ${codecept_run_config('codecept.conf.pass_all_test.js', '@RunRerun - fail second test')} --debug`, + (err, stdout) => { + expect(stdout).toContain('Process run 1 of max 3, success runs 1/3') + expect(stdout).toContain('Fail run 2 of max 3, success runs 1/3') + expect(stdout).toContain('Process run 3 of max 3, success runs 2/3') + expect(stdout).toContain('Flaky tests detected!') + expect(err.code).toBe(1) + done() + }, + ) + }) })