Detox Driver

Drop-in replacement for import { by, element, expect, waitFor, device } from 'detox'. Your existing Detox specs run against Peach’s canvas with no native build.

Running your suite

You don’t wire this up by hand. peach test runs your own Jest, forcing a preset that remaps ^detox$ to the Peach driver, so import ... from 'detox' resolves to Peach without touching your test files:

terminal
peach test e2e/ --app 8081 # discover e2e/ (or test/e2e, detox/) and run against your app
peach test e2e/login.test.ts # run specific files
peach test init --detox # scaffold peach-detox.config.cjs + e2e/example.test.ts
peach test e2e/ --headed # watch it run in a visible browser
peach test e2e/ -t "login" # jest --testNamePattern (also --grep)

The driver creates its own browser context. --no-launch skips the running-shell reachability check; it does not attach to an existing sim. --app <port|url> names the app each device.launchApp() opens, and --port picks the bridge, defaulting to the active local one. The runner picks up config from --config <path>, else peach-detox.config.cjs, any jest.config.*, or a jest key in package.json, else a generated temp config. Your Jest version, transforms, and setup files are preserved.

Matchers

by.id(testID) // match by testID
by.text(text) // match by text content
by.label(label) // match by accessibility label
by.role(role) // match by accessibility role
by.type(componentType) // match by component type

by.id, by.text, and by.label accept strings or regular expressions, matching Detox 20.47.0 on iOS. Strings match exactly. A regular expression’s first match must cover the entire value; use .* for partial matching:

by.text(/.*Welcome.*/)
by.id(/login-.*/)
by.label(/sign in/i)

The i, m, and s flags are supported. Matching uses Unicode; g and y are ignored, so repeated lookups do not advance the expression. A diagnostic such as label == “/sign in/i” describes the regex matcher; it does not mean the slashes are matched literally.

Element actions

element(matcher).tap(point?) // optional {x,y} offset
element(matcher).multiTap(times)
element(matcher).longPress(duration?) // default 1000ms
element(matcher).longPressAndDrag(duration, startX, startY, target, endX, endY)
element(matcher).typeText(text)
element(matcher).replaceText(text)
element(matcher).clearText()
element(matcher).scroll(pixels, direction) // 'up' | 'down' | 'left' | 'right'
element(matcher).scrollTo(edge) // 'top' | 'bottom' | 'left' | 'right'
element(matcher).swipe(direction, speed?, percentage?)
element(matcher).pinch(scale, speed?, angle?) // angle in radians
element(matcher).rotate(radians, speed?)
element(matcher).takeScreenshot(name)
element(matcher).getAttributes()
element(matcher).atIndex(i) // select the zero-based matching node

Assertions

expect(element(matcher)).toExist()
expect(element(matcher)).toBeVisible(percent?) // default 75% visible-area threshold
expect(element(matcher)).toBeNotVisible()
expect(element(matcher)).toHaveText(text) // exact text
expect(element(matcher)).toHaveId(id)
expect(element(matcher)).toHaveLabel(label)
expect(element(matcher)).toHaveAccessibilityRole(role)
expect(element(matcher)).toBeEnabled()
expect(element(matcher)).toHaveValue(value)
// all support the .not prefix

toBeFocused checks focus. toHaveSliderPosition and toHaveToggleValue currently only assert existence.

waitFor

waitFor(element(matcher)).toExist().withTimeout(ms)
waitFor(element(matcher)).toBeVisible().withTimeout(ms)
waitFor(element(matcher)).toBeNotVisible().withTimeout(ms)
waitFor(element(matcher)).toHaveText(text).withTimeout(ms)
waitFor(element(matcher)).toHaveValue(value).withTimeout(ms)
waitFor(element(matcher)).not.toHaveLabel(label).withTimeout(ms)
waitFor(element(matcher)).toHaveId(id).withTimeout(ms)
waitFor(element(matcher)).toBeFocused().withTimeout(ms)
waitFor(element(matcher)).whileElement(by.id('list')).scroll(200, 'down')

These seven conditions support .not, including text, label, id, value, and focus. Detox’s aliases (toNotExist, toBeNotVisible, toBeNotFocused, toNotHaveText, toNotHaveLabel, toNotHaveId, and toNotHaveValue) work on both expect and waitFor. Repeating .not still negates once, as on iOS. withTimeout(0) evaluates once. toHaveValue compares the accessibility value exactly.

Device

device.launchApp(opts?)
device.reloadReactNative()
device.terminateApp()
device.openURL({ url })
device.takeScreenshot(name)
device.takeScreenshotFast(name) // no stability wait
device.startBridgeRecording(opts?)
device.stopAndSaveBridgeRecording(outPath)
device.getPlatform() // 'ios' | 'android'
device.pressBack() // android only
device.setLocation(latitude, longitude) // update this simulator's location
device.sendToHome() // go home and wait for the home screen

No-ops kept for source compatibility (there is no native process in the browser): installApp, uninstallApp, shake, setURLBlacklist.