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_BROWSERSandWDIO_DEVICESsplit on:, not,. Unrecognised entries are dropped silently. - Defaults marked "(injected)" are written into your
envsobject bybuildWdioConfig()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
| Variable | Values | Default | Selects |
|---|---|---|---|
WDIO_REMOTE | local | saucelabs | local | Where the session runs |
WDIO_SCOPE | browser | app | browser | Web app or native app |
WDIO_METAL | desktop | device | desktop | Desktop or mobile device/simulator |
WDIO_PROVIDER | saucelabs | value of WDIO_REMOTE | Overrides 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.
| Variable | Recognised values | Default |
|---|---|---|
WDIO_BROWSERS | chrome, safari, firefox | chrome:safari local / chrome:safari:firefox on Sauce (injected) |
WDIO_DEVICES | android, ios | android: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.
| Variable | Config key | Default |
|---|---|---|
WDIO_MAX_INSTANCES | maxInstances | 100 (forced to 1 when DEBUG is set) |
WDIO_LOG_LEVEL | logLevel | silent |
WDIO_HOSTNAME | hostname | 127.0.0.1 (local); the grid endpoint on cloud branches |
WDIO_PORT | port | 4444 browsers / 4723 Appium (local); 443 on cloud branches |
WDIO_OUTPUT_DIR | outputDir | unset |
WDIO_BAIL | bail | 0 |
WDIO_WAIT_FOR_TIMEOUT | waitforTimeout | 3000 |
WDIO_WAIT_FOR_INTERVAL | waitforInterval | 500 |
WDIO_CONNECTION_RETRY_COUNT | connectionRetryCount | 3 |
WDIO_CONNECTION_RETRY_TIMEOUT | connectionRetryTimeout | 120000 |
WDIO_SPEC_FILE_RETRIES | specFileRetries | 0 |
WDIO_JASMINE_TIMEOUT | jasmineOpts.defaultTimeoutInterval | 5 minutes |
WDIO_MOCHA_TIMEOUT | mochaOpts.timeout | 5 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
| Variable | Values | Default |
|---|---|---|
WDIO_REPORTERS | colon-separated: spec, junit, reportportal, saucecomment | spec local / spec:junit:saucecomment on Sauce (injected) |
SAUCECOMMENT_REPORTER_OUTPUT_DIR | path | build (injected on Sauce) |
SAUCECOMMENT_REPORTER_SAVE_OUTPUT_TO_FILE | true | false | true (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 }),
}
| Variable | Default | Notes |
|---|---|---|
PORT | 4000 | Read from process.env first |
HOST | 0.0.0.0 | Read 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:
| Variable | Capability | Platform |
|---|---|---|
ANDROID_APP / IOS_APP | appium:app | Path to the .apk / .app / .ipa |
APP_PACKAGE / APP_ACTIVITY | appium:appPackage / appium:appActivity | Android launch target |
BUNDLE_ID | appium:bundleId | iOS; use alone to attach to a preinstalled app |
AVD | appium:avd | Android emulator to boot |
ANDROID_DEVICE_NAME / IOS_DEVICE_NAME | appium:deviceName | |
ANDROID_PLATFORM_VERSION / IOS_PLATFORM_VERSION | appium:platformVersion | |
ANDROID_UDID / IOS_UDID | appium:udid | Physical devices |
ANDROID_NO_RESET / IOS_NO_RESET | appium:noReset | Default false |
ANDROID_FULL_RESET / IOS_FULL_RESET | appium:fullReset | Default false |
XCODE_ORG_ID / XCODE_SIGNING_ID | WebDriverAgent signing | Required on real iOS devices |
APPIUM_PORT | Appium server port | Default 4723 |
APPIUM_LOG_LEVEL / APPIUM_LOG_PATH | Appium 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
| Variable | Required | Notes |
|---|---|---|
SAUCE_USERNAME | Yes | |
SAUCE_ACCESS_KEY | Yes | |
SAUCE_REGION | No | Passed to @wdio/sauce-service as region. Note the session endpoint itself is currently fixed at ondemand.us-west-1.saucelabs.com. |
SAUCE_BUILD / SAUCE_NAME | No | Job build and name; otherwise derived from pkgName and a timestamp |
SAUCE_TUNNEL_ID / SAUCE_TUNNEL_OWNER | No | Sauce Connect tunnel; otherwise derived from pkgName |
SAUCE_VISIBILITY | No | Job visibility |
SAUCE_MAX_DURATION | No | Job timeout in seconds, default 1800 |
SAUCE_BROWSER_NAME / SAUCE_BROWSER_VERSION / SAUCE_PLATFORM_NAME | No | Desktop browser targeting |
ANDROID_SAUCE_APP / IOS_SAUCE_APP | For native apps | storage:<fileId> or storage:filename=<name> |
ANDROID_SAUCE_DEVICE_NAME / IOS_SAUCE_DEVICE_NAME | No | Real-device selection |
SAUCE_DEVICE_TYPE | No | phone or tablet |
SAUCE_PHONE_ONLY / SAUCE_TABLET_ONLY | No | Restrict the device pool |
SAUCE_PRIVATE_DEVICES_ONLY / SAUCE_PUBLIC_DEVICES_ONLY | No | Restrict by ownership |
SAUCE_RESIGNING_ENABLED | No | Default true |
SAUCE_CONNECT | No | Default 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.