Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no error thrown from rerun script #4494

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/command/run-rerun.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Comment on lines -20 to -23
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was unused.

const codecept = new Codecept(config, options)

try {
Expand Down
1 change: 1 addition & 0 deletions lib/rerun.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions test/data/sandbox/configs/run-rerun/codecept.conf.pass_all_test.js
Original file line number Diff line number Diff line change
@@ -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',
};
16 changes: 15 additions & 1 deletion test/runner/run_rerun_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -96,4 +96,18 @@ describe('run-rerun command', () => {
},
)
})

it('should throw exit code 1 if all tests were supposed to pass', (done) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified that this test fails without my changes.

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()
},
)
})
})
Loading