Skip to main content

Usage

Swarmdriver reads the environment. This page is the reference for what it reads. For runnable setups per target, see Examples.

Reading the tables​

  • Colon-separated lists. WDIO_REPORTERS, WDIO_BROWSERS and WDIO_DEVICES split on :, not ,. Unrecognised entries are dropped silently.
  • Defaults marked "(injected)" are written into your envs object by buildWdioConfig() when unset. An already-set value always wins.
  • Every optional variable is genuinely optional. A variable whose value matches its default emits no capability at all, so unset variables let WebdriverIO's own defaults apply.

The matrix​

VariableValuesDefaultSelects
WDIO_REMOTElocal | saucelabslocalWhere the session runs
WDIO_SCOPEbrowser | appbrowserWeb app or native app
WDIO_METALdesktop | devicedesktopDesktop or mobile device/simulator
WDIO_PROVIDERsaucelabsvalue of WDIO_REMOTEOverrides which cloud grid handles a non-local run — see Providers

scope=app forces metal=device. Six cells, listed in Architecture.

Targets​

Each entry becomes one capability object, so a two-entry list means two parallel sessions.

VariableRecognised valuesDefault
WDIO_BROWSERSchrome, safari, firefoxchrome:safari local / chrome:safari:firefox on Sauce (injected)
WDIO_DEVICESandroid, iosandroid:ios (injected)
WDIO_BROWSERS=chrome:firefox # 2 capabilities
WDIO_DEVICES=android # 1 capability

edge, ie and anything else are not recognised and are dropped without warning — chrome:firefox:edge yields two capabilities.

Runner settings​

All optional. These map onto standard WebdriverIO config keys.

VariableConfig keyDefault
WDIO_MAX_INSTANCESmaxInstances100 (forced to 1 when DEBUG is set)
WDIO_LOG_LEVELlogLevelsilent
WDIO_HOSTNAMEhostname127.0.0.1 (local); the grid endpoint on cloud branches
WDIO_PORTport4444 browsers / 4723 Appium (local); 443 on cloud branches
WDIO_OUTPUT_DIRoutputDirunset
WDIO_BAILbail0
WDIO_WAIT_FOR_TIMEOUTwaitforTimeout3000
WDIO_WAIT_FOR_INTERVALwaitforInterval500
WDIO_CONNECTION_RETRY_COUNTconnectionRetryCount3
WDIO_CONNECTION_RETRY_TIMEOUTconnectionRetryTimeout120000
WDIO_SPEC_FILE_RETRIESspecFileRetries0
WDIO_JASMINE_TIMEOUTjasmineOpts.defaultTimeoutInterval5 minutes
WDIO_MOCHA_TIMEOUTmochaOpts.timeout5 minutes
DEBUG—Sets maxInstances: 1; useful for readable local output

SWARMDRIVER_LOG_LEVEL controls swarmdriver's own logger (trace … error), separately from WDIO_LOG_LEVEL. It is read from process.env directly, not from the envs bag you pass to buildWdioConfig().

Reporters​

VariableValuesDefault
WDIO_REPORTERScolon-separated: spec, junit, reportportal, saucecommentspec local / spec:junit:saucecomment on Sauce (injected)
SAUCECOMMENT_REPORTER_OUTPUT_DIRpathbuild (injected on Sauce)
SAUCECOMMENT_REPORTER_SAVE_OUTPUT_TO_FILEtrue | falsetrue (injected on Sauce)

saucecomment writes results back onto the Sauce job, which is why it is a Sauce-branch default rather than a global one.

Base URL helper​

calcBaseUrl() is a helper, not something buildWdioConfig() calls — the returned config has no baseUrl unless you set one.

import { buildWdioConfig, calcBaseUrl } from '@caps/core'

export const config = {
...buildWdioConfig({ envs: process.env }),
specs: ['./test/specs/**/*.spec.js'],
baseUrl: calcBaseUrl({ envs: process.env }),
}
VariableDefaultNotes
PORT4000Read from process.env first
HOST0.0.0.0Read from process.env first
SWARMDRIVER_PORT—Fallback when PORT is unset
SWARMDRIVER_HOST—Fallback when HOST is unset

calcHostname({ envs, metal }) is the companion: it returns localhost for metal=desktop and the machine's first non-internal IPv4 address for metal=device, because Chrome on Android will not resolve localhost back to your dev machine.

Appium and native apps​

Local native-app runs read a large Appium surface. The commonly used subset:

VariableCapabilityPlatform
ANDROID_APP / IOS_APPappium:appPath to the .apk / .app / .ipa
APP_PACKAGE / APP_ACTIVITYappium:appPackage / appium:appActivityAndroid launch target
BUNDLE_IDappium:bundleIdiOS; use alone to attach to a preinstalled app
AVDappium:avdAndroid emulator to boot
ANDROID_DEVICE_NAME / IOS_DEVICE_NAMEappium:deviceName
ANDROID_PLATFORM_VERSION / IOS_PLATFORM_VERSIONappium:platformVersion
ANDROID_UDID / IOS_UDIDappium:udidPhysical devices
ANDROID_NO_RESET / IOS_NO_RESETappium:noResetDefault false
ANDROID_FULL_RESET / IOS_FULL_RESETappium:fullResetDefault false
XCODE_ORG_ID / XCODE_SIGNING_IDWebDriverAgent signingRequired on real iOS devices
APPIUM_PORTAppium server portDefault 4723
APPIUM_LOG_LEVEL / APPIUM_LOG_PATHAppium server logging

Roughly 120 Appium and driver variables are wired up in total — localisation, logcat, MJPEG streaming, keystores, simulator settings and more. The generated TypeDoc for parseAppiumSettings, parseAndroidAppiumSettings and parseIosAppiumSettings in the API Reference is the exhaustive list.

Sauce Labs​

VariableRequiredNotes
SAUCE_USERNAMEYes
SAUCE_ACCESS_KEYYes
SAUCE_REGIONNoPassed to @wdio/sauce-service as region. Note the session endpoint itself is currently fixed at ondemand.us-west-1.saucelabs.com.
SAUCE_BUILD / SAUCE_NAMENoJob build and name; otherwise derived from pkgName and a timestamp
SAUCE_TUNNEL_ID / SAUCE_TUNNEL_OWNERNoSauce Connect tunnel; otherwise derived from pkgName
SAUCE_VISIBILITYNoJob visibility
SAUCE_MAX_DURATIONNoJob timeout in seconds, default 1800
SAUCE_BROWSER_NAME / SAUCE_BROWSER_VERSION / SAUCE_PLATFORM_NAMENoDesktop browser targeting
ANDROID_SAUCE_APP / IOS_SAUCE_APPFor native appsstorage:<fileId> or storage:filename=<name>
ANDROID_SAUCE_DEVICE_NAME / IOS_SAUCE_DEVICE_NAMENoReal-device selection
SAUCE_DEVICE_TYPENophone or tablet
SAUCE_PHONE_ONLY / SAUCE_TABLET_ONLYNoRestrict the device pool
SAUCE_PRIVATE_DEVICES_ONLY / SAUCE_PUBLIC_DEVICES_ONLYNoRestrict by ownership
SAUCE_RESIGNING_ENABLEDNoDefault true
SAUCE_CONNECTNoDefault false

Overriding the generated config​

buildWdioConfig() accepts only the options in its signature — envs, remote, scope, metal, framework, pkgName. Anything else you pass is ignored. Apply overrides on the way out:

import '@caps/providers'
import { buildWdioConfig } from '@caps/core'

export const config = {
...buildWdioConfig({
envs: process.env,
remote: process.env.WDIO_REMOTE || 'local',
scope: process.env.WDIO_SCOPE || 'browser',
metal: process.env.WDIO_METAL || 'desktop',
framework: 'jasmine',
pkgName: 'my-e2e-suite',
}),

// yours, applied after
specs: ['./test/specs/**/*.spec.js'],
exclude: ['./test/specs/wip/**'],
maxInstances: 4,

async before() {
await browser.setWindowSize(1440, 900)
},
}

pkgName is the one option worth setting deliberately: it seeds Sauce tunnel and build identifiers, so runs from different suites stay distinguishable in the Sauce dashboard.

For the full set of WebdriverIO keys you can override, see WebdriverIO Configuration.