11const ChildProcess = require ( 'node:child_process' ) ;
2+ const { iosDevice } = require ( './ios-devices' ) ;
23
3- const CI_AVD_NAME = 'e2e_emulator' ;
4+ // Should be kept in sync with the constant defined in e2e workflow file
5+ const DEFAULT_CI_AVD_NAME = 'e2e_emulator' ;
46
57const isRunningCI = process . env . CI != null ;
68
7- // Assumes that local developement is done on arm64-v8a.
9+ // Assumes that local development is done on arm64-v8a.
810const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a' ;
911// test-butler requires AOSP emulator image, which is not available to download for arm64-v8a in Android Studio SDK Manager, therefore
1012// it is assumed here that arm64-v8a AOSP emulator is not available in local setup.
1113const testButlerApkPath = isRunningCI ? [ '../Example/e2e/apps/test-butler-app-2.2.1.apk' ] : undefined ;
1214
1315function detectLocalAndroidEmulator ( ) {
14- // "DETOX_AVD_NAME " can be set for local developement
15- const detoxAvdName = process . env . DETOX_AVD_NAME ?? null ;
16- if ( detoxAvdName !== null ) {
17- return detoxAvdName
16+ // "RNS_E2E_AVD_NAME " can be set for local development
17+ const avdName = process . env . RNS_E2E_AVD_NAME ?? null ;
18+ if ( avdName !== null ) {
19+ return avdName
1820 }
1921
2022 // Fallback: try to use Android SDK
2123 try {
22- let stdout = ChildProcess . execSync ( "emulator -list-avds" )
24+ let stdout = ChildProcess . execSync ( "emulator -list-avds" ) ;
2325
2426 // Possibly convert Buffer to string
2527 if ( typeof stdout !== 'string' ) {
@@ -32,22 +34,22 @@ function detectLocalAndroidEmulator() {
3234 throw new Error ( 'No installed AVDs detected on the device' ) ;
3335 }
3436
35- // Just select first one in the list.
37+ // Just select first one in the list.
3638 // TODO: consider giving user a choice here.
3739 return avdList [ 0 ] ;
3840 } catch ( error ) {
39- const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME " env variable pointing to one. Cause: ${ error } `
41+ const errorMessage = `Failed to find Android emulator. Set "RNS_E2E_AVD_NAME " env variable pointing to one. Cause: ${ error } ` ;
4042 console . error ( errorMessage ) ;
4143 throw new Error ( errorMessage ) ;
4244 }
4345}
4446
4547function detectAndroidEmulatorName ( ) {
46- return isRunningCI ? CI_AVD_NAME : detectLocalAndroidEmulator ( ) ;
48+ // "RNS_E2E_AVD_NAME" can be set for local development
49+ return isRunningCI ? DEFAULT_CI_AVD_NAME : detectLocalAndroidEmulator ( ) ;
4750}
4851
4952/**
50- * @type {Detox.DetoxConfig }
5153 * @param {string } applicationName name (FabricExample / ScreensExample)
5254 * @returns {Detox.DetoxConfig }
5355 */
@@ -94,14 +96,12 @@ function commonDetoxConfigFactory(applicationName) {
9496 devices : {
9597 simulator : {
9698 type : 'ios.simulator' ,
97- device : {
98- type : 'iPhone 16 Pro' ,
99- } ,
99+ device : iosDevice ,
100100 } ,
101101 attached : {
102102 type : 'android.attached' ,
103103 device : {
104- adbName : CI_AVD_NAME ,
104+ adbName : process . env . RNS_ADB_NAME ,
105105 } ,
106106 utilBinaryPaths : testButlerApkPath ,
107107 } ,
@@ -147,10 +147,10 @@ function commonDetoxConfigFactory(applicationName) {
147147 app : 'android.release' ,
148148 } ,
149149 } ,
150- }
150+ } ;
151151}
152152
153153module . exports = {
154154 commonDetoxConfigFactory,
155155 isRunningCI,
156- }
156+ } ;
0 commit comments