Skip to content
Open
Show file tree
Hide file tree
Changes from all 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: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ testpullfilecache*
.DS_Store
package-lock.json
yarn.lock
/.vs
typings/types.d.ts
typings/promiseBasedTypes.d.ts
Comment on lines -24 to -25
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Annoyingly, TSLint was failing because these files weren't committed to the repo 🙃.

/.vs
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)
}
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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the actual fix, which causes the run-rerun command to properly set the exit code to 1.

} 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) => {
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