Skip to content

Commit 0792f47

Browse files
authored
Merge pull request #7 from gkushang/feature/update-dashboard
Update SauceLabs Dashboard with Automated Build ID
2 parents 89b42ea + 0989576 commit 0792f47

File tree

4 files changed

+53
-17
lines changed

4 files changed

+53
-17
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ typings/
6262

6363
# lockfile
6464
package-lock.json
65+
66+
#idea
67+
/.idea

index.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,27 @@ class SauceHelper extends Helper {
1212
super(config);
1313
}
1414

15+
/**
16+
*
17+
* @param test
18+
* @private
19+
* @author Kushang Gajjar
20+
*/
21+
_before(test) {
22+
return this._updateSauceJob({
23+
tags: test.tags,
24+
name: test.title,
25+
build: test.build || process.env.SAUCE_BUILD
26+
});
27+
}
28+
1529
/**
1630
*
1731
* @param data Test name, etc
1832
* @private
1933
*/
2034
_updateSauceJob(data) {
21-
const restHelper = this.helpers["REST"];
35+
const restHelper = this.helpers.REST;
2236
if (!restHelper) {
2337
throw new Error("REST helper must be enabled, add REST: {} to helpers config");
2438
}
@@ -43,7 +57,7 @@ class SauceHelper extends Helper {
4357
* @private
4458
*/
4559
_passed(test) {
46-
return this._updateSauceJob({ passed: true, name: test.title });
60+
return this._updateSauceJob({ passed: true });
4761
}
4862

4963
/**
@@ -53,7 +67,7 @@ class SauceHelper extends Helper {
5367
* @private
5468
*/
5569
_failed(test, error) {
56-
return this._updateSauceJob({ passed: false, name: test.title });
70+
return this._updateSauceJob({ passed: false });
5771
}
5872

5973
_createAuthHeader(config) {
@@ -74,27 +88,27 @@ class SauceHelper extends Helper {
7488
}
7589

7690
_getConfig() {
77-
if (this.helpers["WebDriver"]) {
78-
return this.helpers["WebDriver"].config;
91+
if (this.helpers.WebDriver) {
92+
return this.helpers.WebDriver.config;
7993
}
80-
if (this.helpers["Appium"]) {
81-
return this.helpers["Appium"].config;
94+
if (this.helpers.Appium) {
95+
return this.helpers.Appium.config;
8296
}
83-
if (this.helpers["WebDriverIO"]) {
84-
return this.helpers["WebDriverIO"].config;
97+
if (this.helpers.WebDriverIO) {
98+
return this.helpers.WebDriverIO.config;
8599
}
86100
throw new Error("No matching helper found. Supported helpers: WebDriver/Appium/WebDriverIO");
87101
}
88102

89103
_getSessionId() {
90-
if (this.helpers["WebDriver"]) {
91-
return this.helpers["WebDriver"].browser.sessionId;
104+
if (this.helpers.WebDriver) {
105+
return this.helpers.WebDriver.browser.sessionId;
92106
}
93-
if (this.helpers["Appium"]) {
94-
return this.helpers["Appium"].browser.sessionId;
107+
if (this.helpers.Appium) {
108+
return this.helpers.Appium.browser.sessionId;
95109
}
96-
if (this.helpers["WebDriverIO"]) {
97-
return this.helpers["WebDriverIO"].browser.requestHandler.sessionID;
110+
if (this.helpers.WebDriverIO) {
111+
return this.helpers.WebDriverIO.browser.requestHandler.sessionID;
98112
}
99113
throw new Error("No matching helper found. Supported helpers: WebDriver/Appium/WebDriverIO");
100114
}

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414
],
1515
"author": "Puneet Kala <[email protected]>",
1616
"contributors": [
17-
"Jonathan Sharpe <[email protected]>"
17+
{
18+
"name": "Jonathan Sharpe",
19+
"email": "[email protected]"
20+
},
21+
{
22+
"name": "Kushang Gajjar",
23+
"url": "https://github.com/gkushang",
24+
"email": "[email protected]"
25+
}
1826
],
1927
"scripts": {
2028
"lint": "eslint .",

readme.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,20 @@ Example:
2121
}
2222
}
2323
```
24-
2524
Your Sauce Labs user and key are now accessed from the WebDriver/Appium configuration to minimise duplication.
2625

26+
### SauceLabs Automated Build Dashboard
27+
28+
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,
29+
30+
```bash
31+
32+
$ SAUCE_BUILD=<your_build> <test_command>
33+
34+
```
35+
36+
e.g. SAUCE_BUILD=`'date'`
37+
2738
### Development
2839

2940
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.

0 commit comments

Comments
 (0)