diff --git a/lib/rerun.js b/lib/rerun.js index a4f700ffe..fdbad655d 100644 --- a/lib/rerun.js +++ b/lib/rerun.js @@ -73,7 +73,8 @@ class CodeceptRerunner extends BaseCodecept { output.error(e.stack) throw e } finally { - event.emit(event.all.result, this) + // Ensure we emit the correct result object for listeners + event.emit(event.all.result, container.result()) event.emit(event.all.after, this) } } diff --git a/package.json b/package.json index 183419d28..113c6e1d9 100644 --- a/package.json +++ b/package.json @@ -84,16 +84,16 @@ "acorn": "8.15.0", "arrify": "3.0.0", "axios": "1.12.2", - "chalk": "4.1.2", + "chalk": "^4.1.2", "cheerio": "^1.0.0", "chokidar": "^4.0.3", - "commander": "11.1.0", + "commander": "^11.1.0", "cross-spawn": "7.0.6", "css-to-xpath": "0.1.0", "csstoxpath": "1.6.0", "envinfo": "7.14.0", "escape-string-regexp": "4.0.0", - "figures": "3.2.0", + "figures": "^3.2.0", "fn-args": "4.0.0", "fs-extra": "11.3.2", "fuse.js": "^7.0.0", @@ -107,9 +107,9 @@ "lodash.merge": "4.6.2", "lodash.shuffle": "4.2.0", "mkdirp": "3.0.1", - "mocha": "11.7.2", + "mocha": "^11.7.2", "monocart-coverage-reports": "2.12.9", - "ms": "2.1.3", + "ms": "^2.1.3", "multer": "^2.0.2", "ora-classic": "5.4.2", "parse-function": "5.6.10", diff --git a/test/runner/run_rerun_test.js b/test/runner/run_rerun_test.js index 7ec5d0d2d..426d81ee7 100644 --- a/test/runner/run_rerun_test.js +++ b/test/runner/run_rerun_test.js @@ -78,6 +78,23 @@ describe('run-rerun command', () => { }) }) + it('should emit correct result object and not show OK when tests fail', done => { + exec(`${codecept_run_config('codecept.conf.fail_test.js', '@RunRerun - Fail all attempt')}`, (err, stdout) => { + // Should show individual run failures correctly + expect(stdout).toContain('FAIL |') + expect(stdout).toContain('failed') + + // Should not show "OK | 0 passed" when tests actually failed + expect(stdout).not.toContain('OK | 0 passed') + + // Should show the expected error message for flaky tests + expect(stdout).toContain('Flaky tests detected!') + + expect(err.code).toBe(1) + 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) => { expect(stdout).toContain('Process run 1 of max 3, success runs 1/2')