11const ChildProcess = require ( 'node:child_process' ) ;
22const { iosDevice } = require ( './ios-devices' ) ;
33
4- const RNS_CI_AVD_NAME = 'e2e_emulator' ;
4+ const DEFAULT_CI_AVD_NAME = 'e2e_emulator' ;
55
66const isRunningCI = process . env . CI != null ;
77
@@ -12,12 +12,6 @@ const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a';
1212const testButlerApkPath = isRunningCI ? [ '../Example/e2e/apps/test-butler-app-2.2.1.apk' ] : undefined ;
1313
1414function detectLocalAndroidEmulator ( ) {
15- // "RNS_DETOX_AVD_NAME" can be set for local developement
16- const detoxAvdName = process . env . RNS_DETOX_AVD_NAME ?? null ;
17- if ( detoxAvdName !== null ) {
18- return detoxAvdName
19- }
20-
2115 // Fallback: try to use Android SDK
2216 try {
2317 let stdout = ChildProcess . execSync ( "emulator -list-avds" )
@@ -33,18 +27,21 @@ function detectLocalAndroidEmulator() {
3327 throw new Error ( 'No installed AVDs detected on the device' ) ;
3428 }
3529
36- // Just select first one in the list.
30+ // Just select first one in the list.
3731 // TODO: consider giving user a choice here.
3832 return avdList [ 0 ] ;
3933 } catch ( error ) {
40- const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME" env variable pointing to one. Cause: ${ error } `
34+ const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME" env variable pointing to one. Cause: ${ error } ` ;
4135 console . error ( errorMessage ) ;
4236 throw new Error ( errorMessage ) ;
4337 }
4438}
4539
4640function detectAndroidEmulatorName ( ) {
47- return isRunningCI ? RNS_CI_AVD_NAME : detectLocalAndroidEmulator ( ) ;
41+ // "RNS_E2E_AVD_NAME" can be set for local developement
42+ return process . env . RNS_E2E_AVD_NAME || isRunningCI
43+ ? DEFAULT_CI_AVD_NAME
44+ : detectLocalAndroidEmulator ( ) ;
4845}
4946
5047/**
@@ -145,10 +142,10 @@ function commonDetoxConfigFactory(applicationName) {
145142 app : 'android.release' ,
146143 } ,
147144 } ,
148- }
145+ } ;
149146}
150147
151148module . exports = {
152149 commonDetoxConfigFactory,
153150 isRunningCI,
154- }
151+ } ;
0 commit comments