Saucelabs doesn't pickup job status correctly
Thanks to @DavertMik our tests now post links to their jobs on saucelabs in the travis log. However on saucelabs they are all listed as a status of "?" (complete) instead of pass/fail. Reading the SauceLabs documentation it wasn't clear to me if reporting the test results to saucelabs is something I need to do manually or something codeceptjs is supposed to be doing automatically.
Sorry, I don't know much on this topic. However you are pointing to unit testing documentation on SauceLas which is nothing to do with CodeceptJS and Selenium.
if reporting the test results to saucelabs is something I need to do manually or something codeceptjs is supposed to be doing automatically.
CodeceptJS doesn't do it automatically
@DavertMik Oops. I don't think that was the link I meant to put in. I think this was the link I meant: https://wiki.saucelabs.com/display/DOCS/Setting+Test+Status+to+Pass+or+Fail
Looks like it wont be too difficult for us to implement, so you can close this if you want. Since the last framework we used did it automatically I thought maybe it was intended for CodeceptJS to do it as well, hence the issue.
If anyone else finds this via google or something, this is how I am doing this right now:
_after() {
if (process.env.SAUCE_USERNAME) {
var sessionId = this.helpers['WebDriverIO'].browser.requestHandler.sessionID;
var sauce_url = "Test finished. Link to job: https://saucelabs.com/jobs/";
sauce_url = sauce_url.concat(sessionId);
console.log(sauce_url);
var dataString = '{"passed": true}';
var status_url = 'https://saucelabs.com/rest/v1/';
status_url = status_url.concat(process.env.SAUCE_USERNAME);
status_url = status_url.concat('/jobs/');
status_url = status_url.concat(sessionId);
var options = {
url: status_url,
method: 'PUT',
body: dataString,
auth: {
'user': process.env.SAUCE_USERNAME,
'pass': process.env.SAUCE_ACCESS_KEY
}
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
request(options, callback);
}
}
@waryhermit The above code says "passed" even the test case is failed on sauce labs. The job status is updated to "passed" in sauce labs even test is failed. Is there anything I should add apart from above code ?
well if you are still wondering for a workaround on this, I have managed to publish this https://www.npmjs.com/package/codeceptjs-saucehelper Feel free to use it, updates with the correct status and test names. @shrikanthkm07 @waryhermit