I've faced with issue using Webdriver.io+Browserstack. When I'm running tests in browser (Automate service) it's ok, I see a correct statuses http://prntscr.com/ijw1rr , but when I'm running for mobile apps tests (App Automate) it shows me always Completed http://prntscr.com/ijw277
Where in wdio.conf.js I should paste this request from REST API documentation REST API? Also I've found here something similar, but don't know how can I use it. Browserstack reports successful even when test fails in Nightwatchjs
Here is an example when it works for me
afterTest: function (test) {
var session = browser.sessionId;
var request = require("request");
request({uri: "https:/<user>:<key>@api.browserstack.com/app-automate/sessions/"+session+".json", method:"PUT", form:{"status":"completed","reason":""}});
}
But it is like hard coded (every time will completed or failed, depends on what I specified), I need somehow populate this value depends on if assert or test fails.
You could use the following code block to mark tests as failed on browserstack
afterTest: test => {
if (!test.passed) {
request({
uri: `https://${user}:${key}@api.browserstack.com/app-automate/sessions/${browser.sessionId}.json`,
method:'PUT',
form:{ 'status':'error','reason': errors.join(' | ') },
})
}
This api call will be invoked only upon test failures. So all test that are completed will be green and the ones that failed will be marked red/error/failed.