saucelabs-connector
Helps connect the local machine to SauceLabs and start a remote browser. The reason that this repo is exist is to acommodate saucelabs and testcafe integration behind proxy, the previous implementation doesn't contain proxy setting for connecting to saucelabs REST API and for tunnel connection.
Install
$ npm install @otr/saucelabs-connector
Publishing the package
$ npm run publish
will build the library and publish it to @otr nexus registry
Development note
Please make sure to use node version 10.x to develop this plugin
Usage
var SauceLabsConnector = require('saucelabs-connector');
var browserInfo = {
platform: 'Windows 10',
browserName: 'chrome',
version: '45.0'
};
var pageUrl = 'www.example.com';
var jobTimeout = 60;
var jobOptions = {
jobName: 'Sample tests',
build: 'build-1234',
tags: ['tag1', 'tag2', 'tag3']
};
var saucelabsConnector = new SauceLabsConnector('SAUCELABS_USERNAME', 'SAUCELABS_ACCESS_KEY');
var saucelabsBrowser = null;
saucelabsConnector
.connect()
.then(function () {
var machineCount = 3;
var requestInterval = 30000;
var maxAttemptCount = 5;
return saucelabsConnector.waitForFreeMachines(machineCount, requestInterval, maxAttemptCount);
})
.then(function () {
return saucelabsConnector.startBrowser(browserInfo, pageUrl, jobOptions, jobTimeout);
})
.then(function (browser) {
saucelabsBrowser = browser;
})
.then(function () {
return saucelabsConnector.stopBrowser(saucelabsBrowser);
})
.then(function () {
return saucelabsConnector.disconnect();
});
Additional Configuration
You can select the data center you want to connect to, by setting the environment variable SAUCE_API_HOST
to the respective data center's host:
export SAUCE_API_HOST=saucelabs.com
export SAUCE_API_HOST=eu-central-1.saucelabs.com