Detox fails unless Android emulator is running prior to test execution - Exceeded timeout of 300000ms while handling jest-circus "setup" event
See original GitHub issueWhat 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?
- I have followed the instructions under Identifying which synchronization mechanism causes us to wait too much.
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:
- Created a year ago
- Reactions:1
- Comments:25 (3 by maintainers)
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.
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…