|
| 1 | +const { |
| 2 | + SAUCE_USERNAME, |
| 3 | + SAUCE_ACCESS_KEY, |
| 4 | + TRAVIS_JOB_NUMBER, |
| 5 | + CI, |
| 6 | + BROWSER_NAME = 'chrome', |
| 7 | + BROWSER_VERSION = 'latest', |
| 8 | + BROWSER_PLATFORM, |
| 9 | + PLATFORM_VERSION, |
| 10 | + DEVICE_NAME, |
| 11 | + DEFAULT_WAIT_TIME = 9000 |
| 12 | +} = process.env; |
| 13 | +const MOBILE_PLATFORMS = ['iOS', 'Android']; |
| 14 | + |
| 15 | +// Local selenium config |
| 16 | +const commonConfigObj = { |
| 17 | + browser: BROWSER_NAME, |
| 18 | + url: 'http://localhost:8080', |
| 19 | + restart: true, |
| 20 | + waitForTimeout: DEFAULT_WAIT_TIME |
| 21 | +}; |
| 22 | + |
| 23 | +const helperObj = {}; |
| 24 | +const isLocalBuild = typeof SAUCE_USERNAME === 'undefined'; |
| 25 | + |
| 26 | +if (isLocalBuild) { |
| 27 | + helperObj.WebDriverIO = commonConfigObj; |
| 28 | +} else { |
| 29 | + // Common saucelab config |
| 30 | + const sauceObj = { |
| 31 | + host: 'ondemand.saucelabs.com', |
| 32 | + port: 80, |
| 33 | + user: SAUCE_USERNAME, |
| 34 | + key: SAUCE_ACCESS_KEY, |
| 35 | + desiredCapabilities: { |
| 36 | + name: CI ? 'Travis cron' : require('os').userInfo().username, // eslint-disable-line global-require |
| 37 | + build: TRAVIS_JOB_NUMBER, |
| 38 | + 'tunnel-identifier': TRAVIS_JOB_NUMBER, |
| 39 | + browserName: BROWSER_NAME, |
| 40 | + platform: BROWSER_PLATFORM |
| 41 | + } |
| 42 | + }; |
| 43 | + |
| 44 | + const mixedInSauceObj = Object.assign({}, commonConfigObj, sauceObj); |
| 45 | + if (MOBILE_PLATFORMS.indexOf(BROWSER_PLATFORM) === -1) { |
| 46 | + // webdriver (desktop) |
| 47 | + Object.assign(sauceObj.desiredCapabilities, { |
| 48 | + version: BROWSER_VERSION |
| 49 | + }); |
| 50 | + helperObj.WebDriverIO = mixedInSauceObj; |
| 51 | + } else { |
| 52 | + // appium (mobile) |
| 53 | + Object.assign(sauceObj.desiredCapabilities, { |
| 54 | + platformVersion: PLATFORM_VERSION, |
| 55 | + deviceName: DEVICE_NAME, |
| 56 | + deviceOrientation: 'portrait', |
| 57 | + appiumVersion: '1.7.2', |
| 58 | + platformName: BROWSER_PLATFORM |
| 59 | + }); |
| 60 | + helperObj.Appium = mixedInSauceObj; |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +exports.config = { |
| 65 | + tests: './functional-tests/tests/*.js', |
| 66 | + timeout: DEFAULT_WAIT_TIME, |
| 67 | + output: './functional-tests/output', |
| 68 | + helpers: helperObj, |
| 69 | + include: {}, |
| 70 | + bootstrap: './functional-tests/helpers/cleanup.js', |
| 71 | + teardown: './functional-tests/helpers/cleanup.js', |
| 72 | + mocha: {}, |
| 73 | + name: 'box-annotations', |
| 74 | + hooks: isLocalBuild ? [] : ['./functional-tests/helpers/eventHooks.js'] |
| 75 | +}; |
0 commit comments