generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make module_test runner & example handle failures correctly
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
1 parent
a321136
commit d4bb813
Showing
2 changed files
with
47 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.