0

Is it possible to disable synchronization before/during launchApp (with newInstance: true)? Ideally I'd like the:

await device.launchApp({ newInstance: true, url });

to resolve immediately.

I've inherited an app that does weird things at launch, so I'd like to bypass synchronization at the beginning and only reenable it afterwards.

I tried something like this:

await device.disableSynchronization();
await device.launchApp({ newInstance: true, url });
await waitFor(element(by.id('root'))).toBeVisible().withTimeout(10000);
await device.enableSynchronization();

but from the docs I read that synchronization is always re-enabled for new instances.

Is there a way to force synchronization to be off so that device.launchApp can actually resolve?

ecesena
  • 1,155
  • 1
  • 12
  • 19

1 Answers1

2

This is now possible using the launch argument -detoxEnableSynchronization NO.

See the documentation here: https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md#10-detoxenablesynchronizationinitialize-detox-with-synchronization-enabled-or-disabled-at-app-launch


Old answer:

Detox does not support disabling synchronization on launch, but if a network request is causing issues, you can pass a URL blacklist as a launch argument, which will disable synchronization for that network request.

await device.launchApp({
  newInstance: true,
  launchArgs: { detoxURLBlacklistRegex: ' \\("http://192.168.1.253:19001/onchange","https://e.crashlytics.com/spi/v2/events"\\)' },
});

https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md#10-initialize-the-url-blacklist-at-device-launch

Léo Natan
  • 56,823
  • 9
  • 150
  • 195