Skip to main content

Swarmdriver

One wdio.conf.js for every target. Swarmdriver turns three environment variables into a valid WebdriverIO 9 + Appium config — local or cloud, browser or native app, desktop or device.

The problem​

Most teams testing a web app and a mobile app end up with six setup scripts: local-chrome, local-android, local-ios, sauce-chrome, sauce-android, sauce-ios. Six files that drift apart, five of which are broken at any given moment, and a capabilities block that has been copy-pasted so many times nobody knows which keys still matter.

Swarmdriver replaces all six with one config and a matrix:

wdio run wdio.conf.js # local Chrome
WDIO_METAL=device wdio run wdio.conf.js # local Android + iOS browsers
WDIO_SCOPE=app wdio run wdio.conf.js # local native apps
WDIO_REMOTE=saucelabs wdio run wdio.conf.js # Sauce desktop browsers
WDIO_REMOTE=saucelabs WDIO_METAL=device wdio run wdio.conf.js # Sauce mobile browsers
WDIO_REMOTE=saucelabs WDIO_SCOPE=app wdio run wdio.conf.js # Sauce real devices

Same file, same specs, same CI job definition. Only the environment changes.

The config​

// wdio.conf.js
import '@caps/providers' // registers cloud grids (see below)
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',
}),
specs: ['./test/specs/**/*.spec.js'],
}

That is the whole integration. buildWdioConfig() handles drivers, Appium, services, reporters, and W3C-correct capabilities for whichever cell you land in.

The matrix​

AxisValuesSelects
WDIO_REMOTElocal | saucelabsWhere the session runs
WDIO_SCOPEbrowser | appWeb app or native app
WDIO_METALdesktop | deviceDesktop machine or mobile device/simulator

scope=app implies metal=device — you cannot run a native mobile app on a desktop — so the matrix has six reachable cells. All six are exercised against WebdriverIO 9's real config parser on every CI run.

One thing that will bite you​

Cloud grids live in a separate package and register themselves on import:

import '@caps/providers' // ← bare, side-effect import
import { buildWdioConfig } from '@caps/core'

Without it, buildWdioConfig({ remote: 'saucelabs' }) returns undefined — no error, no warning. @caps/core owns the provider registry but ships no implementations, which is what keeps the two packages from depending on each other in a cycle. Architecture explains the trade-off; Providers has the full contract.

Next​