Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ typings/

# lockfile
package-lock.json

#idea
/.idea
44 changes: 29 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@ class SauceHelper extends Helper {
super(config);
}

/**
*
* @param test
* @private
* @author Kushang Gajjar
*/
_before(test) {
return this._updateSauceJob({
tags: test.tags,
name: test.title,
build: test.build || process.env.SAUCE_BUILD
});
}

/**
*
* @param data Test name, etc
* @private
*/
_updateSauceJob(data) {
const restHelper = this.helpers["REST"];
const restHelper = this.helpers.REST;
if (!restHelper) {
throw new Error("REST helper must be enabled, add REST: {} to helpers config");
}
Expand All @@ -43,7 +57,7 @@ class SauceHelper extends Helper {
* @private
*/
_passed(test) {
return this._updateSauceJob({ passed: true, name: test.title });
return this._updateSauceJob({ passed: true });
}

/**
Expand All @@ -53,7 +67,7 @@ class SauceHelper extends Helper {
* @private
*/
_failed(test, error) {
return this._updateSauceJob({ passed: false, name: test.title });
return this._updateSauceJob({ passed: false });
}

_createAuthHeader(config) {
Expand All @@ -74,27 +88,27 @@ class SauceHelper extends Helper {
}

_getConfig() {
if (this.helpers["WebDriver"]) {
return this.helpers["WebDriver"].config;
if (this.helpers.WebDriver) {
return this.helpers.WebDriver.config;
}
if (this.helpers["Appium"]) {
return this.helpers["Appium"].config;
if (this.helpers.Appium) {
return this.helpers.Appium.config;
}
if (this.helpers["WebDriverIO"]) {
return this.helpers["WebDriverIO"].config;
if (this.helpers.WebDriverIO) {
return this.helpers.WebDriverIO.config;
}
throw new Error("No matching helper found. Supported helpers: WebDriver/Appium/WebDriverIO");
}

_getSessionId() {
if (this.helpers["WebDriver"]) {
return this.helpers["WebDriver"].browser.sessionId;
if (this.helpers.WebDriver) {
return this.helpers.WebDriver.browser.sessionId;
}
if (this.helpers["Appium"]) {
return this.helpers["Appium"].browser.sessionId;
if (this.helpers.Appium) {
return this.helpers.Appium.browser.sessionId;
}
if (this.helpers["WebDriverIO"]) {
return this.helpers["WebDriverIO"].browser.requestHandler.sessionID;
if (this.helpers.WebDriverIO) {
return this.helpers.WebDriverIO.browser.requestHandler.sessionID;
}
throw new Error("No matching helper found. Supported helpers: WebDriver/Appium/WebDriverIO");
}
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
],
"author": "Puneet Kala <[email protected]>",
"contributors": [
"Jonathan Sharpe <[email protected]>"
{
"name": "Jonathan Sharpe",
"email": "[email protected]"
},
{
"name": "Kushang Gajjar",
"url": "https://github.com/gkushang",
"email": "[email protected]"
}
],
"scripts": {
"lint": "eslint .",
Expand Down
13 changes: 12 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ Example:
}
}
```

Your Sauce Labs user and key are now accessed from the WebDriver/Appium configuration to minimise duplication.

### SauceLabs Automated Build Dashboard

To create SauceLabs Automated Build dashboard, you'd need to pass the unique `build` id. You can pass the unique `build` through process environment variable,

```bash

$ SAUCE_BUILD=<your_build> <test_command>

```

e.g. SAUCE_BUILD=`'date'`

### Development

Code quality and functionality are checked with ESlint (`npm run lint`) and Jest (`npm run test`). The tests use [`nock`][1] to check that appropriate requests are made to the Sauce Labs API given the configuration and the outcome of the test.
Expand Down