question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detox fails unless Android emulator is running prior to test execution - Exceeded timeout of 300000ms while handling jest-circus "setup" event

See original GitHub issue

What happened?

I followed the Detox setup guide for a simple React Native test app I am working on. I managed to setup an Android Emulator which is compatible with Detox, and my first test works great!

The only issue is that my Android Emulator must be running before I execute my detox test command. Otherwise, running detox test launches my Android Emulator and hangs. The error message is Exceeded timeout of 300000ms while handling jest-circus "setup" event.

What was the expected behaviour?

Running detox test for an Emulator config should:

  • - attach to the corresponding Emulator if it is already running and execute tests
  • - launch the corresponding Emulator if it is not running and execute tests

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!

  • Generate a new React Native app
  • Follow the Detox Setup Guide for creating a first test on an Android Emulator with Jest, creating an Android Emulator config
  • Execute detox test for the Android Emulator config while the Emulator is not active
  • The Emulator should launch, but the app will not launch on the Emulator and execution should hang and eventually timeout

In what environment did this happen?

Detox version: 19.6.5 React Native version: 0.66.3 Node version: 16.13.0 Device model: Pixel 5 (emulator) Android version: API 32 Test-runner: jest-circus

Detox logs

Detox logs
11:46:19.836 detox[33000] DEBUG: [ALLOCATE_DEVICE] Trying to allocate a device based on "Pixel_5_API_32"
11:46:19.837 detox[33000] DEBUG: [EXEC_CMD, #2] "/Users/myUserName/Library/Android/sdk/platform-tools/adb"  devices
11:46:20.030 detox[33000] DEBUG: [EXEC_SUCCESS, #2] List of devices attached


11:46:20.031 detox[33000] DEBUG: [ALLOCATE_DEVICE] Settled on emulator-13184
11:46:20.032 detox[33000] DEBUG: [SPAWN_CMD] /Users/myUserName/Library/Android/sdk/emulator/emulator -verbose -no-audio -no-boot-anim -port 13184 @Pixel_5_API_32
11:46:39.690 detox[33000] ERROR: Exceeded timeout of 20000ms while handling jest-circus "setup" event
11:46:39.725 detox[33000] ERROR: Aborted detox.init() execution, and now running detox.cleanup()

HINT: Most likely, your test runner is tearing down the suite due to the timeout error

Device logs

Device logs
{"name":"detox","hostname":"myHostName.local","pid":33133,"__filename":"EmulatorAllocationHelper.js","level":20,"event":"ALLOCATE_DEVICE","msg":"Settled on emulator-15278","time":"2022-04-21T16:49:07.933Z","v":0}
{"name":"detox","hostname":"myHostName.local","pid":33133,"__filename":"launchEmulatorProcess.js","fn":"boot","level":20,"event":"SPAWN_CMD","msg":"/Users/myUserName/Library/Android/sdk/emulator/emulator -verbose -no-audio -no-boot-anim -port 15278 @Pixel_5_API_32","time":"2022-04-21T16:49:07.934Z","v":0}
{"name":"detox","hostname":"myHostName.local","pid":33133,"level":50,"msg":"Exceeded timeout of 20000ms while handling jest-circus \"setup\" event","time":"2022-04-21T16:49:27.775Z","v":0}
{"name":"detox","hostname":"myHostName.local","pid":33133,"__filename":"ArtifactsManager.js","level":10,"event":"ARTIFACTS_LIFECYCLE","fn":"onBeforeCleanup","msg":"artifactsManager.onBeforeCleanup()","time":"2022-04-21T16:49:27.803Z","v":0}

More data, please!

I’ve tried creating a number of Android Emulators on various devices and APIs to see if the issue persists. This issue persists on Android Emulators for each of the Pixel models (1-5) and for the last several APIs (28-32).

Also, adding --retries 2 to the end of my test script does not alleviate the issue. The process still times out on the first attempt and hangs without retrying.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:25 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
ghitiercommented, May 20, 2022

I’m encountering this issue as well using AOSP API 32. The detox init ends up timing out in the same scenario (app not launched prior to detox test), therefore the tests fail.

Despite the workaround of launching the emulator manually, I’d suggest this to be re-evaluated as a potential bug (instead of a question), and the issue re-opened.

4reactions
MoOxcommented, Jun 30, 2022

There is definitely a bug here. Should not be closed. It’s very difficult and confusing to find the reason of this problem on CI for example…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detox Exceeded timeout of 600000ms while handling jest ...
Detox Exceeded timeout of 600000ms while handling jest-circus "setup" ... Jest did not exit one second after the test run has completed.
Read more >
wix - Bountysource
I've been trying to setup Detox on my project, for debug build Detox has been running successfully. However, every time I want to...
Read more >
pouchdb-adapter-react-native-sqlite | PouchDB adapter using ...
Detox testing + React Native + PouchDB app: our login test keep failing with timeout because of some PouchDB syncing? copy icon. Copy ......
Read more >
Detox fails unless Android emulator is running prior to test ...
Detox fails unless Android emulator is running prior to test execution - Exceeded timeout of 300000ms while handling jest-circus "setup" event.
Read more >
Issues - Detox - Wix.com - Geeks
Detox fails unless Android emulator is running prior to test execution - Exceeded timeout of 300000ms while handling jest-circus "setup" event.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found