Skip to main content
Version: 20.x

Behavior

If you need to tweak the flow of detox.init() or detox.cleanup() steps, you have a few options to change. These are the default behavior values:

Location

You can define the behavior config section in two ways: globally and locally (per a configuration):

.detoxrc.js
/** @type {Detox.DetoxConfig} */
module.exports = {
behavior: {
/* global section */
},
devices: { /* … */ },
apps: { /* … */ },
configurations: {
'ios.sim.debug': {
device: 'iphone',
app: 'ios.debug',
behavior: {
/* local (per-configuration) section */
},
},
},
};

Default values

{
"behavior": {
"init": {
"reinstallApp": true,
"exposeGlobals": true,
},
"launchApp": "auto",
"cleanup": {
"shutdownDevice": false
}
}
}

Properties

behavior.init.reinstallApp [boolean]

Default: true.

When true, Detox will uninstall and install the app upon the initialization.

Setting it to false forces the tests to use the previously installed app on the device, provided you have installed it beforehand explicitly or manually.

behavior.init.exposeGlobals [boolean]

Default: true.

When true, it forces Detox to expose device, expect, element, by and waitFor as global variables.

When false, you should import them explicitly instead:

const { by, device, expect, element } = require('detox');

or, in TypeScript:

import { by, device, expect, element } from 'detox';

behavior.launchApp [enum]

Default: auto.

Possible values: auto, manual.

When set to manual, Detox won't be launching your app automatically. Instead, it will be waiting until you launch it manually from IDE and press any key to resume the test execution. This is useful when you want to debug the native codebase when running Detox tests.

Also, setting it to manual resets behavior.reinstallApp to false.

behavior.cleanup.shutdownDevice [boolean]

Default: false.

When set to true, Detox will shut down the device after the tests finish.