device.enableSynchronization() doesn’t work and messing with the other tests

Description

In some of my test cases, I have to disable auto synchronisation and wait for an element manually by waitFor API.

  • I have tested this issue on the latest Detox release and it still reproduces

Reproduction

describe("my test suite", async () => {
     it("needs to handle synchronisation manually", async () => {
        await device.disableSynchronization();
        // Doing some stuff
        await waitFor(element(by.id("myElement"))).toBeVisible()
         
        await device.enableSynchronization();
     })

     it("needs to handle synchronisation automatically", async () => {
        // All my tests here is failing because auto synchronisation is disabled ⛔ 
     })
})

But if I relaunch the app, it works.

describe("my test suite", async () => {
     it("needs to handle synchronisation manually", async () => {
        await device.disableSynchronization();
        // Doing some stuff
        await waitFor(element(by.id("myElement"))).toBeVisible()
         
        await device.launch({ newInstance: true });
     })

     it("needs to handle synchronisation automatically", async () => {
        // Everything is fine here ✅ 
     })
})

Expected behavior

The await device.enableSynchronization(); should work as expected and prevent messing with the other test cases.

Environment (please complete the following information):

  • Detox: 18.2.2
  • React Native: 0.63.2
  • Node: 15.5.1
  • Device: Simulator iPhone 11Pro
  • Xcode: 12.4
  • iOS: 14.4
  • macOS: 11.1

Logs

If you are experiencing a timeout in your test

2 thoughts on “device.enableSynchronization() doesn’t work and messing with the other tests

  1. @hamidhadi I tried to reproduce but the issue does not reproduce for me.
    await device.enableSynchronization() works as expected in the example I tried.
    Provide a demo project were a test (another it) is failing after the sequence of disable/enable synchronization

  2. Disabling sync does not do that in all running instances, period. This is not the direction towards solving this issue…