Describe the solution you'd like
It would be great to have the ability to retrieve the number of passed/failed tests on completion of a test run.
Describe alternatives you've considered
@erwinheitzman suggested a solution like something below, however, the data that is collected in afterTest can't be accessed in onComplete.
let numberOfFailedTests = 0
afterTest(test) {
if (!test.passed) numberOfFailedTests++
}
onComplete() {
// do something with pass/fail test values
}
Additional context
This would be useful for a number of things. For the specific implementation, I am using the mochawesome-report and at the end of the test run, that entire directory containing the test report is zipped up and uploaded to S3, at which point an email is sent to the stakeholders with a link to said zip file. I would love the ability to include in that email the number of tests that passed or failed.
An additional implementation we'd like to incorporate is with Slack, which would basically do the same thing as above by hitting a Slack channel when a test run completes and there was a failed test.
@pfluegs : Not a solution for propagating pass/fail metrics to the onComplete hook, but since you mentioned slack notifications I would like to suggest this: wdio-slack-reporter.
Thanks for the suggestion @kmnaid. I will definitely take a look.
@pfluegs I hope you don't mind, this seem simple enough and I went and did it. It could easily be done by adding a new argument to the onComplete function and passing in the results from the interface through the launcher as such:
Launcher
await config.onComplete(exitCode, config, caps, this.interface.result)
config file
onComplete(exitCode, config, caps, results) {
// do stuff
// results: { finished: XX, passed: YY, failed: ZZ }
}
Let's continue convo in #3013. Thanks for adding that change @baruchvlz.