Skip to content

Commit

Permalink
Add new flag to allow post hook scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jessica-jorgenson committed Apr 18, 2023
1 parent b466f6a commit 055657e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const args = arg(
'-n': Number,
'--until-passes': Boolean,
'--rerun-failed-only': Boolean,
'--allow-post-hook': Boolean,
},
{ permissive: true },
)
Expand All @@ -29,6 +30,8 @@ const untilPasses = '--until-passes' in args ? args['--until-passes'] : false
const rerunFailedOnly =
'--rerun-failed-only' in args ? args['--rerun-failed-only'] : false

const allowPostHook = '--allow-post-hook' in args ? args['--allow-post-hook'] : false

console.log('%s will repeat Cypress command %d time(s)', name, repeatNtimes)

if (untilPasses) {
Expand All @@ -39,6 +42,10 @@ if (rerunFailedOnly) {
console.log('%s it only reruns specs which have failed', name)
}

if (allowPostHook) {
console.log('%s allow post-hook scripts to run after failing tests', name)
}

/**
* Quick and dirty deep clone
*/
Expand Down Expand Up @@ -144,13 +151,14 @@ parseArguments()
console.error('%s run %d of %d failed', name, k + 1, n)
if (k === n - 1) {
console.error('%s no more attempts left', name)
process.exit(testResults.totalFailed)
allowPostHook ? process.exit(0): process.exit(testResults.totalFailed)

}
} else {
if (testResults.totalFailed) {
console.error('%s run %d of %d failed', name, k + 1, n)
if (!rerunFailedOnly || isLastRun) {
process.exit(testResults.totalFailed)
allowPostHook ? process.exit(0): process.exit(testResults.totalFailed)
}
}
}
Expand Down

0 comments on commit 055657e

Please sign in to comment.