When I launch a detox test with an emulator(one that I specify in detox config file) already running, detox finds the emulator, attaches it to it, and runs tests on it.
When I don't have an emulator running, it helps load the emulator itself. But then when detox tries to install the app on the emulator next, it gets stuck and then eventually fails.
Trace logs(trimmed out artifacts config from the log for brevity).
Goto the log entry related to ALLOCATE_DEVICE after which it should've installed the device.
$ detox test -c android.emu.release --loglevel trace
00:24:21.224 detox[17068] INFO: [test.js] DETOX_CONFIGURATION="android.emu.release" DETOX_LOGLEVEL="trace" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1663526361217 DETOX_USE_CUSTOM_LOGGER=true jest --config D:\Myapp\app\mobile\e2e\config.json --testNamePattern "^((?!:ios:).)*$" e2e
00:24:26.614 detox[19864] TRACE: [DETOX_CREATE] created a Detox instance with config:
{
appsConfig: {
default: {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
testBinaryPath: 'android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk',
build: 'cd android && gradlew clean && gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..'
}
},
behaviorConfig: {
init: {
reinstallApp: true,
exposeGlobals: true
},
cleanup: {
shutdownDevice: false
},
launchApp: 'auto'
},
cliConfig: {
configuration: 'android.emu.release',
loglevel: 'trace',
useCustomLogger: true
},
configurationName: 'android.emu.release',
deviceConfig: {
type: 'android.emulator',
gpuMode: 'swiftshader_indirect',
device: {
avdName: '31_aosp'
}
},
runnerConfig: {
testRunner: 'jest',
runnerConfig: 'D:\\Myappp\\app\\mobile\\e2e\\config.json',
specs: 'e2e',
skipLegacyWorkersInjection: true
},
sessionConfig: {
autoStart: true,
sessionId: '8a6a88d9-1e5b-5df3-6cda-4c90f05b1e3b',
debugSynchronization: 10000
}
}
00:24:26.625 detox[19864] DEBUG: [WSS_CREATE] Detox server listening on localhost:51367...
00:24:26.643 detox[19864] DEBUG: [WSS_CONNECTION, #51368] registered a new connection.
00:24:26.645 detox[19864] TRACE: [WS_OPEN] opened web socket to: ws://localhost:51367
00:24:26.647 detox[19864] TRACE: [WS_SEND] {"type":"login","params":{"sessionId":"8a6a88d9-1e5b-5df3-6cda-4c90f05b1e3b","role":"tester"},"messageId":0}
00:24:26.649 detox[19864] TRACE: [WSS_GET_FROM, #51368] {"type":"login","params":{"sessionId":"8a6a88d9-1e5b-5df3-6cda-4c90f05b1e3b","role":"tester"},"messageId":0}
00:24:26.650 detox[19864] TRACE: [SESSION_CREATED] created session 8a6a88d9-1e5b-5df3-6cda-4c90f05b1e3b
00:24:26.651 detox[19864] TRACE: [WSS_SEND_TO, #tester] {"type":"loginSuccess","params":{"testerConnected":true,"appConnected":false},"messageId":0}
00:24:26.652 detox[19864] TRACE: [SESSION_JOINED] tester joined session 8a6a88d9-1e5b-5df3-6cda-4c90f05b1e3b
00:24:26.653 detox[19864] TRACE: [WS_MESSAGE] {"type":"loginSuccess","params":{"testerConnected":true,"appConnected":false},"messageId":0}
00:24:26.754 detox[19864] DEBUG: [EXEC_CMD, #0] "C:\Users\PRADEEP\AppData\Local\Android\Sdk\emulator\emulator.EXE" -list-avds --verbose
00:24:26.826 detox[19864] TRACE: [EXEC_SUCCESS, #0] 31_aosp
31_api
31_playstore
00:24:26.827 detox[19864] DEBUG: [EXEC_CMD, #1] "C:\Users\PRADEEP\AppData\Local\Android\Sdk\emulator\emulator.EXE" -version
00:24:27.413 detox[19864] TRACE: [EXEC_SUCCESS, #1] INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
Android emulator version 31.3.10.0 (build_id 8807927) (CL:N/A)
Copyright (C) 2006-2017 The Android Open Source Project and many others.
This program is a derivative of the QEMU CPU emulator (www.qemu.org).
This software is licensed under the terms of the GNU General Public
License version 2, as published by the Free Software Foundation, and
may be copied, distributed, and modified under those terms.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
INFO | Android emulator version 31.3.10.0 (build_id 8807927) (CL:N/A)
00:24:27.416 detox[19864] DEBUG: [EMU_BIN_VERSION_DETECT] Detected emulator binary version { major: 31, minor: 3, patch: 10, toString: [Function: toString] }
00:24:27.416 detox[19864] DEBUG: [ALLOCATE_DEVICE] Trying to allocate a device based on "31_aosp"
00:24:27.419 detox[19864] DEBUG: [EXEC_CMD, #2] "C:\Users\PRADEEP\AppData\Local\Android\Sdk\platform-tools\adb.EXE" devices
00:24:27.520 detox[19864] DEBUG: [EXEC_SUCCESS, #2] List of devices attached
00:24:27.523 detox[19864] DEBUG: [ALLOCATE_DEVICE] Settled on emulator-12586
00:24:27.524 detox[19864] DEBUG: [SPAWN_CMD] C:\Users\PRADEEP\AppData\Local\Android\Sdk\emulator\emulator.EXE -verbose -no-audio -no-boot-anim -gpu swiftshader_indirect -port 12586 @31_aosp
00:26:26.610 detox[19864] ERROR: [DETOX_INIT_ERROR]
DetoxRuntimeError: 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
at DetoxRuntimeErrorComposer.abortedDetoxInit (D:\Myapp\app\mobile\node_modules\detox\src\errors\DetoxRuntimeErrorComposer.js:13:12)
at Detox.[_assertNoPendingInit] (D:\Myapp\app\mobile\node_modules\detox\src\Detox.js:238:48)
at Detox.beforeEach (D:\Myapp\app\mobile\node_modules\detox\src\Detox.js:122:37)
at DetoxExportWrapper.<computed> (D:\Myapp\app\mobile\node_modules\detox\src\DetoxExportWrapper.js:94:32)
at DetoxAdapterImpl.beforeEach (D:\Myapp\app\mobile\node_modules\detox\runners\jest\DetoxAdapterImpl.js:28:22)
at DetoxAdapterJasmine.beforeEach (D:\Myapp\app\mobile\node_modules\detox\runners\jest\DetoxAdapterJasmine.js:20:5)
at Object.<anonymous> (D:\Myapp\app\mobile\e2e\init.ts:21:3)
00:26:26.617 detox[19864] TRACE: [ARTIFACTS_LIFECYCLE] artifactsManager.onBeforeCleanup()
00:26:26.622 detox[19864] DEBUG: [WSS_CLOSE] Detox server has been closed gracefully