From 8cc9c45f3c9efe31cf0780b73888fee0b02c95e0 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Thu, 20 Nov 2025 17:23:09 +0100 Subject: [PATCH 01/13] chore(e2e): detox config cleanup --- .gitignore | 2 ++ Example/.detoxrc.js | 2 +- Example/package.json | 8 +++---- FabricExample/.detoxrc.js | 2 +- FabricExample/package.json | 8 +++---- scripts/{ => e2e}/detox-utils.cjs | 22 +++++++++--------- scripts/e2e/ios-devices.js | 37 +++++++++++++++++++++++++++++++ 7 files changed, 59 insertions(+), 22 deletions(-) rename scripts/{ => e2e}/detox-utils.cjs (90%) create mode 100644 scripts/e2e/ios-devices.js diff --git a/.gitignore b/.gitignore index 6b2d8b4092..5d4e948584 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,5 @@ android/.settings # Local environment (direnv) .envrc +# e2e +*Example/artifacts diff --git a/Example/.detoxrc.js b/Example/.detoxrc.js index 4269d09526..41ed27fecc 100644 --- a/Example/.detoxrc.js +++ b/Example/.detoxrc.js @@ -1,2 +1,2 @@ -const utils = require('../scripts/detox-utils.cjs'); +const utils = require('../scripts/e2e/detox-utils.cjs'); module.exports = utils.commonDetoxConfigFactory('ScreensExample'); diff --git a/Example/package.json b/Example/package.json index c53f43b3da..1a40d54538 100644 --- a/Example/package.json +++ b/Example/package.json @@ -9,10 +9,10 @@ "format": "prettier --write --list-different './src/**/*.{js,ts,tsx}'", "lint": "eslint --ext '.js,.ts,.tsx' --fix src && yarn check-types && yarn format", "check-types": "tsc --noEmit", - "build-e2e-ios": "detox build --configuration ios.release", - "build-e2e-android": "detox build --configuration android.release", - "test-e2e-ios": "detox test --configuration ios.release --take-screenshots failing", - "test-e2e-android": "detox test --configuration android.release --take-screenshots failing", + "build-e2e-ios": "detox build --configuration ios.sim.release", + "build-e2e-android": "detox build --configuration android.emu.release", + "test-e2e-ios": "detox test --configuration ios.sim.release --take-screenshots failing", + "test-e2e-android": "detox test --configuration android.emu.release --take-screenshots failing", "postinstall": "patch-package" }, "dependencies": { diff --git a/FabricExample/.detoxrc.js b/FabricExample/.detoxrc.js index 477f13da53..0b18322286 100644 --- a/FabricExample/.detoxrc.js +++ b/FabricExample/.detoxrc.js @@ -1,3 +1,3 @@ -const utils = require('../scripts/detox-utils.cjs'); +const utils = require('../scripts/e2e/detox-utils.cjs'); module.exports = utils.commonDetoxConfigFactory('FabricExample'); diff --git a/FabricExample/package.json b/FabricExample/package.json index 22c0ed09bb..91199b09f3 100644 --- a/FabricExample/package.json +++ b/FabricExample/package.json @@ -8,10 +8,10 @@ "lint": "eslint .", "start": "npx react-native start", "test": "jest", - "build-e2e-ios": "detox build --configuration ios.release", - "build-e2e-android": "detox build --configuration android.release", - "test-e2e-ios": "detox test --configuration ios.release --take-screenshots failing", - "test-e2e-android": "detox test --configuration android.release --take-screenshots failing", + "build-e2e-ios": "detox build --configuration ios.sim.release", + "build-e2e-android": "detox build --configuration android.emu.release", + "test-e2e-ios": "detox test --configuration ios.sim.release --take-screenshots failing", + "test-e2e-android": "detox test --configuration android.emu.release --take-screenshots failing", "postinstall": "patch-package" }, "dependencies": { diff --git a/scripts/detox-utils.cjs b/scripts/e2e/detox-utils.cjs similarity index 90% rename from scripts/detox-utils.cjs rename to scripts/e2e/detox-utils.cjs index 8f66557200..8b9500008c 100644 --- a/scripts/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -1,6 +1,7 @@ const ChildProcess = require('node:child_process'); +const { iosDevice } = require('./ios-devices'); -const CI_AVD_NAME = 'e2e_emulator'; +const CI_ADB_NAME = 'e2e_emulator'; const isRunningCI = process.env.CI != null; @@ -11,10 +12,10 @@ const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a'; const testButlerApkPath = isRunningCI ? ['../Example/e2e/apps/test-butler-app-2.2.1.apk'] : undefined; function detectLocalAndroidEmulator() { - // "DETOX_AVD_NAME" can be set for local developement - const detoxAvdName = process.env.DETOX_AVD_NAME ?? null; - if (detoxAvdName !== null) { - return detoxAvdName + // "DETOX_ADB_NAME" can be set for local developement + const detoxAdbName = process.env.DETOX_ADB_NAME ?? null; + if (detoxAdbName !== null) { + return detoxAdbName } // Fallback: try to use Android SDK @@ -36,18 +37,17 @@ function detectLocalAndroidEmulator() { // TODO: consider giving user a choice here. return avdList[0]; } catch (error) { - const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME" env variable pointing to one. Cause: ${error}` + const errorMessage = `Failed to find Android emulator. Set "DETOX_ADB_NAME" env variable pointing to one. Cause: ${error}` console.error(errorMessage); throw new Error(errorMessage); } } function detectAndroidEmulatorName() { - return isRunningCI ? CI_AVD_NAME : detectLocalAndroidEmulator(); + return isRunningCI ? CI_ADB_NAME : detectLocalAndroidEmulator(); } /** - * @type {Detox.DetoxConfig} * @param {string} applicationName name (FabricExample / ScreensExample) * @returns {Detox.DetoxConfig} */ @@ -94,14 +94,12 @@ function commonDetoxConfigFactory(applicationName) { devices: { simulator: { type: 'ios.simulator', - device: { - type: 'iPhone 16 Pro', - }, + device: iosDevice, }, attached: { type: 'android.attached', device: { - adbName: CI_AVD_NAME, + adbName: CI_ADB_NAME, }, utilBinaryPaths: testButlerApkPath, }, diff --git a/scripts/e2e/ios-devices.js b/scripts/e2e/ios-devices.js new file mode 100644 index 0000000000..e3caad8e44 --- /dev/null +++ b/scripts/e2e/ios-devices.js @@ -0,0 +1,37 @@ +const DEFEAULT_APPLE_MODEL = 'iPhone 17'; +const DEVICE_MODEL = process.env.E2E_APPLE_DEVICE || DEFEAULT_APPLE_MODEL +const DEFEAULT_IOS_VERSION = 'iOS 26.2'; + +/** + * @return {`iOS ${string}`} requested version of ios, or default if not specified + */ +function getiosVersion() { + const passedVersion = process.env.E2E_IOS_VERSION; + if (passedVersion) { + if (passedVersion.startsWith('iOS ')) { + return /** @type {`iOS ${string}`} */ (passedVersion); + } + return `iOS ${passedVersion}`; + } + return DEFEAULT_IOS_VERSION; +} + +/** + * @typedef {Object} AppleDevice - creates a new type named 'SpecialType' + * @property {string} type - a string which represents a model of an iPhone + * @property {`iOS ${string}`} os - operation system version + */ + +/** + * @satisfies {AppleDevice} + * @readonly + * */ +const iosDevice = { + type: DEVICE_MODEL, + os: getiosVersion(), +}; + +module.exports = { + iosDevice, + getiosVersion, +}; From fe083d32175a78412c5acdab2310682f58a1046c Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar <49615091+KrzysztofWojnar@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:12:50 +0100 Subject: [PATCH 02/13] chore(e2e): Apply suggestions from code review (typos only) Co-authored-by: Kacper Kafara --- scripts/e2e/ios-devices.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/ios-devices.js b/scripts/e2e/ios-devices.js index e3caad8e44..61a570d1c1 100644 --- a/scripts/e2e/ios-devices.js +++ b/scripts/e2e/ios-devices.js @@ -1,11 +1,11 @@ -const DEFEAULT_APPLE_MODEL = 'iPhone 17'; +const DEFAULT_APPLE_MODEL = 'iPhone 17'; const DEVICE_MODEL = process.env.E2E_APPLE_DEVICE || DEFEAULT_APPLE_MODEL const DEFEAULT_IOS_VERSION = 'iOS 26.2'; /** * @return {`iOS ${string}`} requested version of ios, or default if not specified */ -function getiosVersion() { +function getIOSVersion() { const passedVersion = process.env.E2E_IOS_VERSION; if (passedVersion) { if (passedVersion.startsWith('iOS ')) { From 18d4c8f19f69befcb734544ebc0957c06d23d5c4 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Thu, 20 Nov 2025 22:40:39 +0100 Subject: [PATCH 03/13] chore(e2e): review comments applied --- scripts/e2e/detox-utils.cjs | 12 ++++++------ scripts/e2e/ios-devices.js | 30 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index 8b9500008c..26e3d6feb7 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -12,10 +12,10 @@ const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a'; const testButlerApkPath = isRunningCI ? ['../Example/e2e/apps/test-butler-app-2.2.1.apk'] : undefined; function detectLocalAndroidEmulator() { - // "DETOX_ADB_NAME" can be set for local developement - const detoxAdbName = process.env.DETOX_ADB_NAME ?? null; - if (detoxAdbName !== null) { - return detoxAdbName + // "DETOX_AVD_NAME" can be set for local developement + const detoxAvdName = process.env.DETOX_AVD_NAME ?? null; + if (detoxAvdName !== null) { + return detoxAvdName } // Fallback: try to use Android SDK @@ -37,14 +37,14 @@ function detectLocalAndroidEmulator() { // TODO: consider giving user a choice here. return avdList[0]; } catch (error) { - const errorMessage = `Failed to find Android emulator. Set "DETOX_ADB_NAME" env variable pointing to one. Cause: ${error}` + const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME" env variable pointing to one. Cause: ${error}` console.error(errorMessage); throw new Error(errorMessage); } } function detectAndroidEmulatorName() { - return isRunningCI ? CI_ADB_NAME : detectLocalAndroidEmulator(); + return isRunningCI ? CI_ADB_NAME : detectLocalAndroidEmulator(); // ?? } /** diff --git a/scripts/e2e/ios-devices.js b/scripts/e2e/ios-devices.js index 61a570d1c1..2e59192235 100644 --- a/scripts/e2e/ios-devices.js +++ b/scripts/e2e/ios-devices.js @@ -1,19 +1,24 @@ -const DEFAULT_APPLE_MODEL = 'iPhone 17'; -const DEVICE_MODEL = process.env.E2E_APPLE_DEVICE || DEFEAULT_APPLE_MODEL +const DEFAULT_APPLE_DEVICE = 'iPhone 17'; const DEFEAULT_IOS_VERSION = 'iOS 26.2'; +/** + * @return {string} + */ +function getAppleDevice() { + return process.env.E2E_APPLE_DEVICE || DEFAULT_APPLE_DEVICE; +} /** * @return {`iOS ${string}`} requested version of ios, or default if not specified */ function getIOSVersion() { - const passedVersion = process.env.E2E_IOS_VERSION; - if (passedVersion) { - if (passedVersion.startsWith('iOS ')) { - return /** @type {`iOS ${string}`} */ (passedVersion); - } - return `iOS ${passedVersion}`; + const passedVersion = process.env.E2E_IOS_VERSION; + if (passedVersion) { + if (passedVersion.startsWith('iOS ')) { + return /** @type {`iOS ${string}`} */ (passedVersion); } - return DEFEAULT_IOS_VERSION; + return `iOS ${passedVersion}`; + } + return DEFEAULT_IOS_VERSION; } /** @@ -22,16 +27,15 @@ function getIOSVersion() { * @property {`iOS ${string}`} os - operation system version */ -/** +/** * @satisfies {AppleDevice} * @readonly * */ const iosDevice = { - type: DEVICE_MODEL, - os: getiosVersion(), + type: getAppleDevice(), + os: getIOSVersion(), }; module.exports = { iosDevice, - getiosVersion, }; From 44a73b62525803ef32c0340219a9fd80016de167 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Fri, 21 Nov 2025 11:10:57 +0100 Subject: [PATCH 04/13] chore(e2e): prefix RNS for env variables --- scripts/e2e/detox-utils.cjs | 10 +++++----- scripts/e2e/ios-devices.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index 26e3d6feb7..e8be7a51c2 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -1,7 +1,7 @@ const ChildProcess = require('node:child_process'); const { iosDevice } = require('./ios-devices'); -const CI_ADB_NAME = 'e2e_emulator'; +const RNS_CI_AVD_NAME = 'e2e_emulator'; const isRunningCI = process.env.CI != null; @@ -12,8 +12,8 @@ const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a'; const testButlerApkPath = isRunningCI ? ['../Example/e2e/apps/test-butler-app-2.2.1.apk'] : undefined; function detectLocalAndroidEmulator() { - // "DETOX_AVD_NAME" can be set for local developement - const detoxAvdName = process.env.DETOX_AVD_NAME ?? null; + // "RNS_DETOX_AVD_NAME" can be set for local developement + const detoxAvdName = process.env.RNS_DETOX_AVD_NAME ?? null; if (detoxAvdName !== null) { return detoxAvdName } @@ -44,7 +44,7 @@ function detectLocalAndroidEmulator() { } function detectAndroidEmulatorName() { - return isRunningCI ? CI_ADB_NAME : detectLocalAndroidEmulator(); // ?? + return isRunningCI ? RNS_CI_AVD_NAME : detectLocalAndroidEmulator(); // ?? } /** @@ -99,7 +99,7 @@ function commonDetoxConfigFactory(applicationName) { attached: { type: 'android.attached', device: { - adbName: CI_ADB_NAME, + avdName: RNS_CI_AVD_NAME, }, utilBinaryPaths: testButlerApkPath, }, diff --git a/scripts/e2e/ios-devices.js b/scripts/e2e/ios-devices.js index 2e59192235..e1d2ed3cd1 100644 --- a/scripts/e2e/ios-devices.js +++ b/scripts/e2e/ios-devices.js @@ -5,13 +5,13 @@ const DEFEAULT_IOS_VERSION = 'iOS 26.2'; * @return {string} */ function getAppleDevice() { - return process.env.E2E_APPLE_DEVICE || DEFAULT_APPLE_DEVICE; + return process.env.RNS_E2E_APPLE_DEVICE || DEFAULT_APPLE_DEVICE; } /** * @return {`iOS ${string}`} requested version of ios, or default if not specified */ function getIOSVersion() { - const passedVersion = process.env.E2E_IOS_VERSION; + const passedVersion = process.env.RNS_E2E_IOS_VERSION; if (passedVersion) { if (passedVersion.startsWith('iOS ')) { return /** @type {`iOS ${string}`} */ (passedVersion); From 12d4b5706b225ba0a4645421bd82dc6095ea6ec0 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Fri, 21 Nov 2025 11:47:57 +0100 Subject: [PATCH 05/13] chore(e2e): RNS_E2E_APPLE_DEVICE renamed to RNS_E2E_APPLE_SIM_NAME --- scripts/e2e/ios-devices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/e2e/ios-devices.js b/scripts/e2e/ios-devices.js index e1d2ed3cd1..b4538c07d8 100644 --- a/scripts/e2e/ios-devices.js +++ b/scripts/e2e/ios-devices.js @@ -5,7 +5,7 @@ const DEFEAULT_IOS_VERSION = 'iOS 26.2'; * @return {string} */ function getAppleDevice() { - return process.env.RNS_E2E_APPLE_DEVICE || DEFAULT_APPLE_DEVICE; + return process.env.RNS_E2E_APPLE_SIM_NAME || DEFAULT_APPLE_DEVICE; } /** * @return {`iOS ${string}`} requested version of ios, or default if not specified From 03d413b14b2437f34db4e04e81b6ec0505659b29 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Fri, 21 Nov 2025 11:49:35 +0100 Subject: [PATCH 06/13] chore(e2e): new env variable RNS_ADB_NAME introduced for attached android devices --- scripts/e2e/detox-utils.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index e8be7a51c2..b5e9c8807f 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -44,7 +44,7 @@ function detectLocalAndroidEmulator() { } function detectAndroidEmulatorName() { - return isRunningCI ? RNS_CI_AVD_NAME : detectLocalAndroidEmulator(); // ?? + return isRunningCI ? RNS_CI_AVD_NAME : detectLocalAndroidEmulator(); } /** @@ -99,7 +99,7 @@ function commonDetoxConfigFactory(applicationName) { attached: { type: 'android.attached', device: { - avdName: RNS_CI_AVD_NAME, + avdName: process.env.RNS_ADB_NAME, }, utilBinaryPaths: testButlerApkPath, }, From ab2b23521a2d0dcf40096221292a0a3099c47c3c Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Fri, 21 Nov 2025 13:35:14 +0100 Subject: [PATCH 07/13] chore(e2e): unified to RNS_E2E_AVD_NAME env var --- .github/workflows/android-e2e-test-fabric.yml | 4 ++-- .github/workflows/android-e2e-test.yml | 4 ++-- scripts/e2e/detox-utils.cjs | 21 ++++++++----------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/android-e2e-test-fabric.yml b/.github/workflows/android-e2e-test-fabric.yml index a9f238a403..142584f4ab 100644 --- a/.github/workflows/android-e2e-test-fabric.yml +++ b/.github/workflows/android-e2e-test-fabric.yml @@ -86,7 +86,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - avd-name: e2e_emulator + rns_e2e_avd_name: e2e_emulator arch: x86_64 script: echo "Generated AVD snapshot for caching." @@ -102,7 +102,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - avd-name: e2e_emulator + rns_e2e_avd_name: e2e_emulator arch: x86_64 script: yarn test-e2e-android diff --git a/.github/workflows/android-e2e-test.yml b/.github/workflows/android-e2e-test.yml index c23b88d3c6..443575c3d4 100644 --- a/.github/workflows/android-e2e-test.yml +++ b/.github/workflows/android-e2e-test.yml @@ -86,7 +86,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - avd-name: e2e_emulator + rns_e2e_avd_name: e2e_emulator arch: x86_64 script: echo "Generated AVD snapshot for caching." @@ -102,7 +102,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - avd-name: e2e_emulator + rns_e2e_avd_name: e2e_emulator arch: x86_64 script: yarn test-e2e-android diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index b5e9c8807f..4eda0f40d4 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -1,7 +1,7 @@ const ChildProcess = require('node:child_process'); const { iosDevice } = require('./ios-devices'); -const RNS_CI_AVD_NAME = 'e2e_emulator'; +const DEFAULT_CI_AVD_NAME = 'e2e_emulator'; const isRunningCI = process.env.CI != null; @@ -12,12 +12,6 @@ const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a'; const testButlerApkPath = isRunningCI ? ['../Example/e2e/apps/test-butler-app-2.2.1.apk'] : undefined; function detectLocalAndroidEmulator() { - // "RNS_DETOX_AVD_NAME" can be set for local developement - const detoxAvdName = process.env.RNS_DETOX_AVD_NAME ?? null; - if (detoxAvdName !== null) { - return detoxAvdName - } - // Fallback: try to use Android SDK try { let stdout = ChildProcess.execSync("emulator -list-avds") @@ -33,18 +27,21 @@ function detectLocalAndroidEmulator() { throw new Error('No installed AVDs detected on the device'); } - // Just select first one in the list. + // Just select first one in the list. // TODO: consider giving user a choice here. return avdList[0]; } catch (error) { - const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME" env variable pointing to one. Cause: ${error}` + const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME" env variable pointing to one. Cause: ${error}`; console.error(errorMessage); throw new Error(errorMessage); } } function detectAndroidEmulatorName() { - return isRunningCI ? RNS_CI_AVD_NAME : detectLocalAndroidEmulator(); + // "RNS_E2E_AVD_NAME" can be set for local developement + return process.env.RNS_E2E_AVD_NAME || isRunningCI + ? DEFAULT_CI_AVD_NAME + : detectLocalAndroidEmulator(); } /** @@ -145,10 +142,10 @@ function commonDetoxConfigFactory(applicationName) { app: 'android.release', }, }, - } + }; } module.exports = { commonDetoxConfigFactory, isRunningCI, -} +}; From 8fe0271336e490adc4f2557677b55cf5041dcbe2 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Fri, 21 Nov 2025 13:44:41 +0100 Subject: [PATCH 08/13] chore(e2e): adbName misalignment --- scripts/e2e/detox-utils.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index 4eda0f40d4..e266262be6 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -31,7 +31,7 @@ function detectLocalAndroidEmulator() { // TODO: consider giving user a choice here. return avdList[0]; } catch (error) { - const errorMessage = `Failed to find Android emulator. Set "DETOX_AVD_NAME" env variable pointing to one. Cause: ${error}`; + const errorMessage = `Failed to find Android emulator. Set "RNS_E2E_AVD_NAME" env variable pointing to one. Cause: ${error}`; console.error(errorMessage); throw new Error(errorMessage); } @@ -96,7 +96,7 @@ function commonDetoxConfigFactory(applicationName) { attached: { type: 'android.attached', device: { - avdName: process.env.RNS_ADB_NAME, + adbName: process.env.RNS_ADB_NAME, }, utilBinaryPaths: testButlerApkPath, }, From 3fbdad36fdf853744340054bd346679be36d1ae3 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Fri, 21 Nov 2025 20:31:09 +0100 Subject: [PATCH 09/13] chore(e2e): avd name does NOT come from CI env variables --- .github/workflows/android-e2e-test-fabric.yml | 4 ++-- .github/workflows/android-e2e-test.yml | 4 ++-- scripts/e2e/detox-utils.cjs | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/android-e2e-test-fabric.yml b/.github/workflows/android-e2e-test-fabric.yml index 142584f4ab..a9f238a403 100644 --- a/.github/workflows/android-e2e-test-fabric.yml +++ b/.github/workflows/android-e2e-test-fabric.yml @@ -86,7 +86,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - rns_e2e_avd_name: e2e_emulator + avd-name: e2e_emulator arch: x86_64 script: echo "Generated AVD snapshot for caching." @@ -102,7 +102,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - rns_e2e_avd_name: e2e_emulator + avd-name: e2e_emulator arch: x86_64 script: yarn test-e2e-android diff --git a/.github/workflows/android-e2e-test.yml b/.github/workflows/android-e2e-test.yml index 443575c3d4..c23b88d3c6 100644 --- a/.github/workflows/android-e2e-test.yml +++ b/.github/workflows/android-e2e-test.yml @@ -86,7 +86,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - rns_e2e_avd_name: e2e_emulator + avd-name: e2e_emulator arch: x86_64 script: echo "Generated AVD snapshot for caching." @@ -102,7 +102,7 @@ jobs: disable-animations: false force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - rns_e2e_avd_name: e2e_emulator + avd-name: e2e_emulator arch: x86_64 script: yarn test-e2e-android diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index e266262be6..fb2cc5d80a 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -39,9 +39,8 @@ function detectLocalAndroidEmulator() { function detectAndroidEmulatorName() { // "RNS_E2E_AVD_NAME" can be set for local developement - return process.env.RNS_E2E_AVD_NAME || isRunningCI - ? DEFAULT_CI_AVD_NAME - : detectLocalAndroidEmulator(); + if (isRunningCI) return DEFAULT_CI_AVD_NAME; + return process.env.RNS_E2E_AVD_NAME || detectLocalAndroidEmulator(); } /** From eec4e70083d7a9adc28a39c77860a4aa53d4d3f6 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 21 Nov 2025 18:38:24 +0100 Subject: [PATCH 10/13] Add comment to `DEFAULT_CI_AVD_NAME` constant --- scripts/e2e/detox-utils.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index fb2cc5d80a..a4600fa015 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -1,6 +1,7 @@ const ChildProcess = require('node:child_process'); const { iosDevice } = require('./ios-devices'); +// Should be kept in sync with the constant defined in e2e workflow file const DEFAULT_CI_AVD_NAME = 'e2e_emulator'; const isRunningCI = process.env.CI != null; From 3f5ee0dd604caeef0abd608df72c2701a2d63015 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 21 Nov 2025 19:53:11 +0100 Subject: [PATCH 11/13] Restore previous way of resolving avd name This is just cleaner --- scripts/e2e/detox-utils.cjs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index a4600fa015..f557e64926 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -13,9 +13,15 @@ const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a'; const testButlerApkPath = isRunningCI ? ['../Example/e2e/apps/test-butler-app-2.2.1.apk'] : undefined; function detectLocalAndroidEmulator() { + // "RNS_E2E_AVD_NAME" can be set for local developement + const avdName = process.env.RNS_E2E_AVD_NAME ?? null; + if (avdName !== null) { + return avdName + } + // Fallback: try to use Android SDK try { - let stdout = ChildProcess.execSync("emulator -list-avds") + let stdout = ChildProcess.execSync("emulator -list-avds"); // Possibly convert Buffer to string if (typeof stdout !== 'string') { @@ -40,8 +46,7 @@ function detectLocalAndroidEmulator() { function detectAndroidEmulatorName() { // "RNS_E2E_AVD_NAME" can be set for local developement - if (isRunningCI) return DEFAULT_CI_AVD_NAME; - return process.env.RNS_E2E_AVD_NAME || detectLocalAndroidEmulator(); + return isRunningCI ? DEFAULT_CI_AVD_NAME : detectLocalAndroidEmulator(); } /** From 90009059a34b5d1bb86625195bded244bf180997 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Mon, 24 Nov 2025 11:40:22 +0100 Subject: [PATCH 12/13] chore(e2e): review suggestions --- scripts/e2e/ios-devices.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/e2e/ios-devices.js b/scripts/e2e/ios-devices.js index b4538c07d8..93bd53438b 100644 --- a/scripts/e2e/ios-devices.js +++ b/scripts/e2e/ios-devices.js @@ -5,24 +5,35 @@ const DEFEAULT_IOS_VERSION = 'iOS 26.2'; * @return {string} */ function getAppleDevice() { + const envVariableKey = 'RNS_E2E_APPLE_SIM_NAME'; + const passedDevice = process.env[envVariableKey]; + if (passedDevice) { + if (/^(iPhone|iPad)\s.+/.test(passedDevice)) { + return passedDevice; + } else { + throw new Error(`Environment variable ${envVariableKey} should be "iPhone xyz" or "iPad xyz".`); + } + } return process.env.RNS_E2E_APPLE_SIM_NAME || DEFAULT_APPLE_DEVICE; } /** * @return {`iOS ${string}`} requested version of ios, or default if not specified */ function getIOSVersion() { - const passedVersion = process.env.RNS_E2E_IOS_VERSION; + const envVariableKey = 'RNS_E2E_IOS_VERSION'; + const passedVersion = process.env[envVariableKey]; if (passedVersion) { - if (passedVersion.startsWith('iOS ')) { + if (/^(iOS)\s.+/.test(passedVersion)) { return /** @type {`iOS ${string}`} */ (passedVersion); + } else { + throw new Error(`Environment variable ${envVariableKey} should be "iOS xyz".`); } - return `iOS ${passedVersion}`; } return DEFEAULT_IOS_VERSION; } /** - * @typedef {Object} AppleDevice - creates a new type named 'SpecialType' + * @typedef {Object} AppleDevice - represents Detox's config for an Apple device * @property {string} type - a string which represents a model of an iPhone * @property {`iOS ${string}`} os - operation system version */ From 77e2519c50cd8387f93ec7578f6d0fc8d0a72478 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojnar Date: Mon, 24 Nov 2025 13:04:42 +0100 Subject: [PATCH 13/13] chore(e2e): typos --- scripts/e2e/detox-utils.cjs | 6 +++--- scripts/e2e/ios-devices.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/e2e/detox-utils.cjs b/scripts/e2e/detox-utils.cjs index f557e64926..9d88dc50ef 100644 --- a/scripts/e2e/detox-utils.cjs +++ b/scripts/e2e/detox-utils.cjs @@ -6,14 +6,14 @@ const DEFAULT_CI_AVD_NAME = 'e2e_emulator'; const isRunningCI = process.env.CI != null; -// Assumes that local developement is done on arm64-v8a. +// Assumes that local development is done on arm64-v8a. const apkBulidArchitecture = isRunningCI ? 'x86_64' : 'arm64-v8a'; // test-butler requires AOSP emulator image, which is not available to download for arm64-v8a in Android Studio SDK Manager, therefore // it is assumed here that arm64-v8a AOSP emulator is not available in local setup. const testButlerApkPath = isRunningCI ? ['../Example/e2e/apps/test-butler-app-2.2.1.apk'] : undefined; function detectLocalAndroidEmulator() { - // "RNS_E2E_AVD_NAME" can be set for local developement + // "RNS_E2E_AVD_NAME" can be set for local development const avdName = process.env.RNS_E2E_AVD_NAME ?? null; if (avdName !== null) { return avdName @@ -45,7 +45,7 @@ function detectLocalAndroidEmulator() { } function detectAndroidEmulatorName() { - // "RNS_E2E_AVD_NAME" can be set for local developement + // "RNS_E2E_AVD_NAME" can be set for local development return isRunningCI ? DEFAULT_CI_AVD_NAME : detectLocalAndroidEmulator(); } diff --git a/scripts/e2e/ios-devices.js b/scripts/e2e/ios-devices.js index 93bd53438b..bbb969f81c 100644 --- a/scripts/e2e/ios-devices.js +++ b/scripts/e2e/ios-devices.js @@ -1,5 +1,5 @@ const DEFAULT_APPLE_DEVICE = 'iPhone 17'; -const DEFEAULT_IOS_VERSION = 'iOS 26.2'; +const DEFAULT_IOS_VERSION = 'iOS 26.2'; /** * @return {string} @@ -29,7 +29,7 @@ function getIOSVersion() { throw new Error(`Environment variable ${envVariableKey} should be "iOS xyz".`); } } - return DEFEAULT_IOS_VERSION; + return DEFAULT_IOS_VERSION; } /**