Devices
The format of Detox config allows you to define inside it multiple device configs in a key-value manner, i.e.:
Location
You can define the device config in two ways: aliased and inlined (per a configuration):
.detoxrc.js
/** @type {Detox.DetoxConfig} */
module.exports = {
devices: {
deviceKey: {
/* … device config … */
}
},
/* … */
configurations: {
'example.aliased': {
/* … */
device: 'deviceKey', // (1)
},
'example.inlined': {
/* … */
device: { // (2)
/* … device config … */
},
},
},
};
Examples
- ios.simulator
- android.emulator
- android.attached
- android.genycloud
{
"type": "ios.simulator",
"device": {
// one of these or a combination of them
"id": "D53474CF-7DD1-4673-8517-E75DAD6C34D6",
"type": "iPhone 11 Pro",
"name": "MySim",
"os": "iOS 13.0"
},
}
{
"type": "android.emulator",
"device": {
"avdName": "Pixel_2_API_29"
},
"utilBinaryPaths": [
"optional-property-with/path/to/test-butler-or-anything-else.apk"
],
}
{
"type": "android.attached",
"device": {
"adbName": "YOGAA1BBB412"
}
}
{
"type": "android.genycloud",
"device": {
// one of these:
"recipeUUID": "11111111-2222-3333-4444-555555555555"
"recipeName": "MyRecipeName",
}
}
Properties
A device config can have the following params:
| Configuration Params | Details |
|---|---|
type | Required. String Literal. Mandatory property to discern device types: ios.simulator, android.emulator, android.attached, android.genycloud etc. |
device | Required. Object. Device query, e.g. { "byType": "iPhone 11 Pro" } for iOS simulator, { "avdName": "Pixel_2_API_29" } for Android emulator or { "adbName": "<pattern>" } for attached Android device with name matching the regex. |
bootArgs | Optional. String. Supported by ios.simulator and android.emulator only. Supply an extra String of arguments to xcrun simctl boot ... or emulator -verbose ... @AVD_Name. |
forceAdbInstall | Optional. Boolean. Supported for Android devices only. A Boolean value, false by default. When set to true, it tells device.installApp() to use adb install. Otherwise, it would use the combination of adb push <app.apk> and adb shell pm install. |
utilBinaryPaths | Optional. Array of strings. Supported for Android devices only. An array of relative paths of utility app (APK) binary-files to preinstall on the tested devices - once before the test execution begins. Note: these are not affected by various install-lifecycle events, such as launching an app with device.launchApp({delete: true}), which reinstalls the app. A good example of why this might come in handy is Test Butler. |
gpuMode | Optional. String Literal (auto | host | swiftshader_indirect | angle_indirect | guest). Supported by android.emulator only. A fixed string , which tells in which GPU mode the emulator should be booted. |
headless | Optional. Boolean. false by default. When set to true, it tells Detox to boot an Android emulator with -no-window option, or to not open the iOS Simulator app when running with Android or iOS respectively. |
readonly | Optional. Boolean. Supported by android.emulator only. false by default. When set to true, it forces Detox to boot even a single emulator with -read-only option.Note: when used with multiple workers, this setting has no effect — emulators will be booted always with -read-only. |
systemUI | Optional. String or Object. Supported by Android devices only. Configures the Android System UI for consistent screenshots and test stability. Can be set to "minimal" or "genymotion" (preset configurations) or an object with granular control. When using an object, you can set extends: "minimal" or extends: "genymotion" to start from a preset and override specific properties. All properties accept null to explicitly reset to default behavior. Object properties: - keyboard: 'hide' | 'show' | null - Controls keyboard visibility. Note: For 'hide' to work in Google emulators, set hw.keyboard=yes in AVD configuration.- touches: 'hide' | 'show' | null - Controls touch indicator visibility.- pointerLocationBar: 'hide' | 'show' | null - Controls pointer location bar visibility.- navigationMode: '3-button' | 'gesture' | null - Sets navigation bar mode.- statusBar: Object with the following properties:- notifications: 'show' | 'hide' | null - Controls notification icons visibility.- wifiSignal: 'strong' | 'weak' | 'none' | null - Sets WiFi signal strength indicator.- cellSignal: 'strong' | 'weak' | 'none' | null - Sets cellular signal strength indicator. Note: Some Android versions fail to set the network type (3g, lte, etc.).- batteryLevel: 'full' | 'half' | 'low' | null - Sets battery level indicator.- charging: true | false | null - Controls charging indicator.- clock: string | null - Sets the clock time in "hhmm" format (e.g., "1337" for 13:37). |