This repository was archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
335d9c2
commit e737046
Showing
6 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# hermione-sauce | ||
|
||
Plugin for starting up Sauce Connect when running tests with [hermione](https://github.com/gemini-testing/hermione). | ||
|
||
## Installation | ||
|
||
`npm install hermione-sauce` | ||
|
||
## Configuration | ||
|
||
- Use env variables `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const Sauce = require('./lib/sauce'); | ||
|
||
function expandCredentials(opts) { | ||
if (!opts.username) { | ||
opts.username = process.env.SAUCE_USERNAME; | ||
} | ||
if (!opts.accessKey) { | ||
opts.accessKey = process.env.SAUCE_ACCESS_KEY; | ||
} | ||
if (!opts.username || !opts.accessKey) { | ||
throw Error('Missing Sauce credentials. Did you forget to set SAUCE_USERNAME and/or SAUCE_ACCESS_KEY?'); | ||
} | ||
} | ||
|
||
module.exports = (hermione, opts) => { | ||
expandCredentials(opts); | ||
|
||
const sauce = Sauce.create(opts); | ||
|
||
hermione.on(hermione.events.RUNNER_START, async() => { | ||
const { gridUrl, tunnelIdentifier } = await sauce.start(); | ||
|
||
hermione.config.getBrowserIds().forEach(browserId => { | ||
const browser = hermione.config.forBrowser(browserId); | ||
browser.gridUrl = gridUrl; | ||
browser.desiredCapabilities['tunnel-identifier'] = tunnelIdentifier; | ||
}); | ||
}); | ||
|
||
hermione.on(hermione.events.RUNNER_END, () => { | ||
sauce.stop(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const uuid = require('uuid'); | ||
const { promisify } = require('util'); | ||
const sauceConnectLauncher = require('sauce-connect-launcher'); | ||
const launchSauceConnect = promisify(sauceConnectLauncher); | ||
|
||
module.exports = class Sauce { | ||
static create(config) { | ||
return new this(config); | ||
} | ||
|
||
constructor(config) { | ||
this._config = config; | ||
this._sauceConnectProcess = null; | ||
} | ||
|
||
async start() { | ||
const { username, accessKey, verbose } = this._config; | ||
|
||
const gridUrl = `http://${username}:${accessKey}@ondemand.saucelabs.com:80/wd/hub`; | ||
const tunnelIdentifier = uuid.v4(); | ||
|
||
this._sauceConnectProcess = await launchSauceConnect({ | ||
username, | ||
accessKey, | ||
logger: console.log, | ||
verbose, | ||
tunnelIdentifier | ||
}); | ||
|
||
return { gridUrl, tunnelIdentifier }; | ||
} | ||
|
||
stop() { | ||
return this._sauceConnectProcess.close(); | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "hermione-sauce", | ||
"version": "0.0.0", | ||
"author": "Serhii Kulykov", | ||
"license": "MIT", | ||
"description": "Plugin for starting up Sauce Connect when running tests with hermione", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/web-padawan/hermione-sauce.git" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
], | ||
"keywords": [ | ||
"hermione", | ||
"hermione-plugin", | ||
"saucelabs", | ||
"sauce", | ||
"connect", | ||
"testing" | ||
], | ||
"dependencies": { | ||
"lodash": "^4.17.15", | ||
"sauce-connect-launcher": "^1.3.1", | ||
"uuid": "^2.0.1" | ||
} | ||
} |