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 . |