Skip to content

Commit

Permalink
Make module_test runner & example handle failures correctly
Browse files Browse the repository at this point in the history
The existing runner.js wouldn't exit w/ a non-zero code if either a test
fails, or cypress.run threw an exception. This will handle both cases

Fixes #44
  • Loading branch information
mikelikespie committed Jul 25, 2023
1 parent a321136 commit d4bb813
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 13 deletions.
31 changes: 24 additions & 7 deletions cypress/tests/module_test/runner.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
const cypress = require('cypress')

cypress.run({
headless: true,
}).then(result => {
if (result.status === 'failed') {
process.exit(1);
}
})
async function main() {
try {
const result = await cypress.run({
headless: true,
})

// If any tests have failed, results.failures is non-zero, some tests have failed
if (result.failures) {
console.error('One or more cypress tests have failed')
console.error(result.message)
process.exit(1)
}

if (result.status !== 'finished') {
console.error('Cypress tests failed with status', result.status)
process.exit(2)
}
} catch (e) {
console.error("Cypress encountered unexpected exception. Exiting.", e)
process.exit(3)
}
}

main();
29 changes: 23 additions & 6 deletions docs/rules.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d4bb813

Please sign in to comment.