Skip to content

Commit

Permalink
Merge pull request #1 from DavertMik/patch-1
Browse files Browse the repository at this point in the history
Added support for CodeceptJS 2.0
  • Loading branch information
puneet0191 authored Jan 2, 2019
2 parents 9b80fed + c83741b commit 5e1d54d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

// use any assertion library you like
let request = require('request');
const container = require('codeceptjs').container;

/**
* Sauce Labs Helper for Codeceptjs
Expand Down Expand Up @@ -56,7 +55,7 @@ class SauceHelper extends Helper {
*/
_passed (test) {
console.log ("Test has Passed");
var sessionId = container.helpers().WebDriverIO.browser.requestHandler.sessionID;
const sessionId = this._getSessionId();
this._updateSauceJob(sessionId, {"passed": true, "name": test.title});
}

Expand All @@ -68,9 +67,22 @@ class SauceHelper extends Helper {
*/
_failed (test, error) {
console.log ("Test has failed");
var sessionId = container.helpers().WebDriverIO.browser.requestHandler.sessionID;
const sessionId = this._getSessionId();
this._updateSauceJob(sessionId, {"passed": false, "name": test.title});
}

_getSessionId() {
if (this.helpers['WebDriver']) {
return this.helpers['WebDriver'].browser.sessionId;
}
if (this.helpers['Appium']) {
return this.helpers['Appium'].browser.sessionId;
}
if (this.helpers['WebDriverIO']) {
return this.helpers['WebDriverIO'].browser.requestHandler.sessionID;
}
throw new Error('No matching helper found. Supported helpers: WebDriver/Appium/WebDriverIO');
}
}

module.exports = SauceHelper;

0 comments on commit 5e1d54d

Please sign in to comment.