Skip to main content
app.device controls the app’s process and the device it runs on: start the app again with launch arguments or a deep link, send it to the background, rotate the screen, switch to dark mode, go offline. Each change is undone before the next test (between tests), so tests stay independent. System UI outside the app — permission dialogs, biometrics, notifications — is on system UI; screenshots are on screenshots.

App lifecycle

relaunch(options?)

Types: RelaunchOptions Terminates the app and starts it again — always a new process. The app keeps its data unless clearData or reinstall is set. Resolves once the app has connected.
Without @quiesco/native, an app that cannot start with the link is started first and the link is opened after the launch, with a warning: getInitialURL will not return it then.

terminate()

Stops the app. Until the next relaunch(), every element call fails at once with APP_NOT_RUNNING, without waiting.

sendToBackground()

Goes to the home screen, like the Home button; the process keeps running. Until bringToForeground(), element calls fail with APP_IN_BACKGROUND. Not on the web (ACTION_NOT_SUPPORTED).

bringToForeground()

Brings the backgrounded app back — the same process, not a restart — and waits until it is active and idle. Not on the web (ACTION_NOT_SUPPORTED).

install()

Installs the app binary from the config’s binaryPath (apps). A running app is stopped: start it with relaunch().

uninstall()

Removes the app from the device. The web has nothing to uninstall (ACTION_NOT_SUPPORTED): use relaunch({ clearData: true }) there.

appState

What the test did to the app last: 'running', 'background' or 'terminated'. A property, not a method.

openUrl(url)

The same as app.openUrl: opens a deep link.

pressBack()

The same as app.pressBack: the Android back button, or the browser’s back on the web.

Network ports

reversePort(port)

Makes a port on the host reachable as localhost:port from an Android device (adb reverse). A no-op on the iOS simulator and the web, which share the host’s network.

unreversePort(port)

Removes a forwarding set with reversePort. A no-op on the iOS simulator and the web.

Device state

setOrientation(orientation)

Types: Orientation Rotates the app to 'portrait' or 'landscape' and resolves once the app’s window has the new shape and the app is idle. The app must not lock its orientation (app.json "orientation": "default").

setAppearance(scheme)

Types: ColorScheme Switches the system color scheme to 'light' or 'dark', and checks that the app reports the new one. The app must follow the system (app.json "userInterfaceStyle": "automatic").

setFontScale(scale)

Sets the system text size, from 0.5 to 4, and resolves with the scale applied. iOS uses the nearest Dynamic Type size and applies it live; Android starts the app again (data kept). Not on the web.

setLocale(locale)

Sets the app’s language and region, a BCP 47 tag such as 'ja-JP'; null goes back to the device default. The app is started again with it (data kept).
  • It passes when the app’s preferred language (iOS AppleLanguages, what expo-localization reads) or its JS locale is the new one.
  • iOS resolves Intl and the app’s native strings only to a language listed in CFBundleLocalizations. Without it a warning says so; an app localized in JS works as it is.

setLocation(latitude, longitude)

Sets the simulated GPS position. On Android, emulators only.

setPermission(name, state)

Types: Permission · PermissionState Changes a permission while the app runs. state is 'grant', 'revoke' or 'reset'; the names are those of permissions (camera, microphone, location, notifications, contacts, photos, calendar).
  • Revoke on Android kills the app. Quiesco starts it again (data kept) before resolving, so the app is back on its first screen.
  • 'reset' means not determined, as after a fresh install: the app’s next request shows the system dialog again. Android: revoked, with “don’t ask again” cleared; iOS: simctl privacy reset; web: the browser asks.
  • On iOS, notifications and the camera can only be reset by reinstalling the app. Quiesco reinstalls and starts it, deleting its data (needs binaryPath; a warning says so).
Answering the system’s permission dialog itself is on system UI.

setNetwork(state)

Types: NetworkState 'offline': the app’s new fetch / XMLHttpRequest / WebSocket connections fail as they do without a network. Quiesco’s own connection keeps working, and connections already open stay open. 'online' undoes it.
  • Android also turns Wi-Fi and mobile data off, and the web reports navigator.onLine === false, so NetInfo sees it there.
  • The iOS simulator has no network switch: NetInfo keeps reporting online.
  • It lasts across relaunches, until 'online' or the next test.
To make the app’s own requests not count for idle instead, see runtime synchronization (Detox’s setURLBlacklist is app.sync.ignoreUrls.add() here).

clipboard.set(text)

Writes plain text to the device clipboard, inside the app: what the app pastes. Cleared before the next test.
iOS and Android need @quiesco/native (≥ Phase 6.6).

clipboard.get()

Reads the device clipboard: what the app copied.
iOS and Android need @quiesco/native (≥ Phase 6.6); on iOS a read falls back to simctl pbpaste.

setStatusBar(options)

Types: StatusBarOptions Overrides the status bar — clock, battery, signal — for clean screenshots. Nothing to do on the web, which has no status bar.

resetStatusBar()

Back to the real status bar.

Screenshots

app.device.screenshot() takes a PNG of the screen, an element or a whole scrolling page: see screenshots.

Between tests

  • Before each test Quiesco starts an app a previous test left terminated, and brings a backgrounded one back.
  • Every device change is undone before the next test, and when the session ends: permissions go back to the configured ones, the rest to what the device had. Only what was changed is touched.
  • A call that starts the app again (setLocale, setFontScale on Android, a revoke on Android) leaves it on its first screen.