Detox: Detox UI test for native Android views not working

What happened?

I have a hybrid app with RN I am trying to implement Detox for UI tests, while everything works fine for pages on RN on Android, I am facing an issue with the Android app -

my login page (1st page of the app that is launched every time the app opens ) is completely native. I tried to write a detox test by clicking on the skip button by fetching the element using text and performing tap() method but nothing happened and after some time my test ended due to espresso time out.

expectation - it should have clicked the skip button and navigated to the next screen

can anyone please confirm if I can write detox tests for native Android activities using native views? if yes then why isn’t my way of working

What was the expected behaviour?

expectation - it should have clicked the skip button and navigated to the next screen

Was it tested on latest Detox?

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

Did your test throw out a timeout?

Help us reproduce this issue!

describe('open test page', () => {
  beforeEach(async () => {
    await device.launchApp({
      newInstance: true
    });
  });

  it('should handle TEST page successfully', async () => {
    let continueButton = element(by.text('Skip'))
    await continueButton.tap()
    await expect(element(by.text('Where do you want your service?'))).toBeVisible();
    await expect(continueButton).toBeVisible();
  })
});

In what environment did this happen?

Detox version: 20.13.2 React Native version: 0.67 Has Fabric (React Native’s new rendering system) enabled: No Node version: v21.1.0 / v10.0 Device model: pixel 4 emulator API 33 / API 29 Android version: android 10/ android 13 Test-runner (select one): jest

Detox logs

FAIL e2e/starter.test.js (80.397 s) open test page ✕ should handle TEST page successfully (71379 ms)

● open test page › should handle TEST page successfully

The app has crashed, see the details below:

@Thread detox.primary(217): java.lang.RuntimeException: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.uimodule.UIModuleIdlingResource] to become idle timed out at androidx.test.espresso.Espresso.onIdle(Espresso.java:18) at com.wix.detox.TestEngineFacade.awaitIdle(TestEngineFacade.kt:12) at com.wix.detox.adapters.server.ReadyActionHandler.handle(DetoxActionHandlers.kt:25) at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda-2$lambda-1(DetoxActionsDispatcher.kt:64) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$nk3cF8ntnfFqbJOcVqd04vjb5nY(DetoxActionsDispatcher.kt:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:0) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at com.wix.detox.adapters.server.ActionsExecutor.init$lambda-0(DetoxActionsDispatcher.kt:50) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$Hi5vyewqQiQqk57AkJy_cHqNGKY(DetoxActionsDispatcher.kt:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(R8$$SyntheticClass:0) at java.lang.Thread.run(Thread.java:1012) Caused by: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.uimodule.UIModuleIdlingResource] to become idle timed out at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:191) at androidx.test.espresso.Espresso.onIdle(Espresso.java:12) … 13 more Caused by: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.uimodule.UIModuleIdlingResource] to become idle timed out at androidx.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:4) at androidx.test.espresso.base.UiControllerImpl$5.resourcesHaveTimedOut(UiControllerImpl.java:1) at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleTimeout(IdlingResourceRegistry.java:4) at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleMessage(IdlingResourceRegistry.java:6) at android.os.Handler.dispatchMessage(Handler.java:102) at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:14) at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:8) at androidx.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:16) at androidx.test.espresso.Espresso$1.run(Espresso.java:1) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7872) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Check device logs for full details!

3 | describe(‘open test page’, () => { 4 | beforeEach(async () => {

5 | await device.launchApp({ | ^ 6 | newInstance: true 7 | }); 8 | });

at Object.launchApp (e2e/starter.test.js:5:22) Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 80.448 s Ran all test suites. 19:25:56.918 detox[63623] E Command failed with exit code = 1: jest --config e2e/jest.config.js

Device logs

No response

More data, please!

No response

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 17

Most upvoted comments

Just to provide more context, I’m trying to understand practically if my idea in #4251 will be of any use to you or not.

instead of await device.launchApp({ ... }); paste this

await Promise.race([
  device.launchApp({ newInstance: true }),
  sleep(10000).then(() => device.disableSynchronization()),
]);