Skip to content

Commit

Permalink
Chore: add config for saucelabs naming (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanDeMicco authored Feb 8, 2018
1 parent 48ae594 commit beee7ea
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions codecept.conf.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const DEFAULT_WAIT_TIME = 10000; // 10 seconds
const DEFAULT_WAIT_TIME = 15000; // 15 seconds
const {
SAUCE_USERNAME,
SAUCE_ACCESS_KEY,
TRAVIS_JOB_NUMBER,
CI,
BROWSER_NAME = 'chrome',
BROWSER_VERSION = 'latest',
BROWSER_PLATFORM
BROWSER_PLATFORM,
PLATFORM_VERSION,
DEVICE_NAME
} = process.env;
const MOBILE_PLATFORMS = ['iOS', 'Android'];

// Local selenium config
const webDriverIOlocal = {
Expand All @@ -18,43 +21,48 @@ const webDriverIOlocal = {
waitForTimeout: DEFAULT_WAIT_TIME
};

// CI saucelabs config
let WebDriverIO;
const helperObj = {};
if (typeof SAUCE_USERNAME === 'undefined') {
WebDriverIO = webDriverIOlocal;
helperObj.WebDriverIO = webDriverIOlocal;
} else {
WebDriverIO = Object.assign({}, webDriverIOlocal, {
// Common saucelab config
const sauceObj = {
host: 'ondemand.saucelabs.com',
port: 80,
user: SAUCE_USERNAME,
key: SAUCE_ACCESS_KEY,
desiredCapabilities: {
name: CI ? 'Travis cron' : require('os').userInfo().username, // eslint-disable-line global-require
build: TRAVIS_JOB_NUMBER,
'tunnel-identifier': TRAVIS_JOB_NUMBER,
browserName: BROWSER_NAME,
version: BROWSER_VERSION,
platform: BROWSER_PLATFORM,
chromeOptions: {
args: ['--disable-web-security']
}
platform: BROWSER_PLATFORM
}
});
};

if (!CI) {
// Local saucelabs config
Object.assign(WebDriverIO, {
host: 'localhost',
port: 4445
const mixedInSauceObj = Object.assign({}, webDriverIOlocal, sauceObj);
if (MOBILE_PLATFORMS.indexOf(BROWSER_PLATFORM) === -1) {
// webdriver (desktop)
Object.assign(sauceObj.desiredCapabilities, {
version: BROWSER_VERSION
});
helperObj.WebDriverIO = mixedInSauceObj;
} else {
// appium (mobile)
Object.assign(sauceObj.desiredCapabilities, {
platformVersion: PLATFORM_VERSION,
deviceName: DEVICE_NAME,
deviceOrientation: 'portrait'
});
helperObj.Appium = mixedInSauceObj;
}
}

exports.config = {
tests: './functional-tests/*_test.js',
timeout: DEFAULT_WAIT_TIME,
output: './functional-tests/output',
helpers: {
WebDriverIO
},
helpers: helperObj,
include: {},
bootstrap: false,
mocha: {},
Expand Down

0 comments on commit beee7ea

Please sign in to comment.