Skip to content

Conversation

@KrzysztofWojnar
Copy link
Collaborator

@KrzysztofWojnar KrzysztofWojnar commented Nov 20, 2025

Description

This is first of three PRs in the scope of labs issue 569.

Realizing plans from labs discussion 572.

Changes

e2e tests could be run in more parametrized way - choosing ios version/device before the start.
CI_AVD_NAME and DETOX_AVD_NAME env variables combined into RNS_E2E_AVD_NAME
RNS_ADB_NAME environment variable introduced for local testing against attached [physical] devices.
Common e2e scripts restructured.

Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

Before

Choosing apple simulator by changing config file for "ios.simulator" entry

After

Running test script with optional RNS_E2E_APPLE_SIM_NAME and RNS_E2E_IOS_VERSION environment variables.

Checklist

@kkafar kkafar self-requested a review November 20, 2025 20:12
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Nice job. I have few remarks & questions. Please answer them.


According to https://github.com/software-mansion/react-native-screens-labs/discussions/572 should I expect support for E2E_ANDROID_API_LEVEL in this PR or what are plans for that?


If you want to structure the code this way, i. e. extract the "device" detecting code to separate module, then we should do analogous thing with Android related code. It can be done in separate PR, I don't mind, but let's create ticket for this, so that we do not forget.

const { iosDevice } = require('./ios-devices');

const CI_AVD_NAME = 'e2e_emulator';
const CI_ADB_NAME = 'e2e_emulator';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing from top of my head but:

ADB ~= Android Debug Bridge,
AVD ~= Android Virtual Device.

I believe this variable describes the name of the emulator (avd) we want to use -> avd makes more sense here. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right
when I was doing the cleanup I was sure that we assign it to "adbName" in detox-utils, but we assign it to "avdName" in this case, I'm going to correct that

Copy link
Collaborator Author

@KrzysztofWojnar KrzysztofWojnar Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, no,
This specific variable seems to be used in two places and it looks to me that one case is wrong:
We used it as a devices.attached.device.adbName in line 104->102 and it may be assigned to devices.emulator.device.avdName because of line 46->47

I suspect one of these entries was a dead code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name we specify is clearly an AVD name, not ADB name. Therefore let's name it appropriately, please.

I took a look into Detox docs and it seems that two fields are allowed:

  • avdName - for emulator name as listed by emulators -list-avd
  • adbName - for emulator device hash (? not sure what that hash-like id is) that can be used with ADB to identify the device.

Seems that for the wole time we've been just using the wrong field, unless the e2e CI workflow specifies e2e_emulator as the adb name of the device it creates.

PS: I've just checked and it seems that we specify avd-name field there. Not sure of it exact semantics, but it seems that our detox setup worked so far only by accident. Let's fix that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,37 @@
const DEFEAULT_APPLE_MODEL = 'iPhone 17';
const DEVICE_MODEL = process.env.E2E_APPLE_DEVICE || DEFEAULT_APPLE_MODEL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEVICE_MODEL is not really a constant here. I'd prefer it being extracted to a function and computed there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to detectLocalAndroidEmulator function defined in the "main" util module.

Copy link
Collaborator Author

@KrzysztofWojnar KrzysztofWojnar Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, it makes no difference (okay, now that you've pointed it out, I'd write it camelCase).

Anyway, turned into a function

@KrzysztofWojnar KrzysztofWojnar force-pushed the @KrzysztofWojnar/e2e-config-for-detox-cleanup branch from 3797cfe to 89208a9 Compare November 20, 2025 21:42
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered

const { iosDevice } = require('./ios-devices');

const CI_AVD_NAME = 'e2e_emulator';
const CI_ADB_NAME = 'e2e_emulator';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name we specify is clearly an AVD name, not ADB name. Therefore let's name it appropriately, please.

I took a look into Detox docs and it seems that two fields are allowed:

  • avdName - for emulator name as listed by emulators -list-avd
  • adbName - for emulator device hash (? not sure what that hash-like id is) that can be used with ADB to identify the device.

Seems that for the wole time we've been just using the wrong field, unless the e2e CI workflow specifies e2e_emulator as the adb name of the device it creates.

PS: I've just checked and it seems that we specify avd-name field there. Not sure of it exact semantics, but it seems that our detox setup worked so far only by accident. Let's fix that.

@KrzysztofWojnar KrzysztofWojnar force-pushed the @KrzysztofWojnar/e2e-config-for-detox-cleanup branch from d8762fc to d3d5c5b Compare November 21, 2025 11:07
@KrzysztofWojnar KrzysztofWojnar changed the title chore(e2e): detox config cleanup chore(e2e): detox config general cleanup and ios management Nov 21, 2025
@KrzysztofWojnar KrzysztofWojnar force-pushed the @KrzysztofWojnar/e2e-config-for-detox-cleanup branch from 8192e77 to c5fa206 Compare November 21, 2025 13:13
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have some more remarks. I feel like we're proceeding here in a bit chaotic manner, with some unrequested changes being applied here.

I'll open a diff with suggested changes, so that we can proceed more smoothly. Will link it here once a do

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avd-name is a configuration option from the github action this job step uses. Renaming here does not make much sense. I think you went too far with find & replace 😅

Comment on lines 42 to 44
return process.env.RNS_E2E_AVD_NAME || isRunningCI
? DEFAULT_CI_AVD_NAME
: detectLocalAndroidEmulator();
Copy link
Member

@kkafar kkafar Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have few remarks to this code:

  1. It introduces unnecessary uncertainty how to interpret this. Might be a skill issue on my end, but I prefer to have it written in such way I don't have to wonder whether || operator has higher precedence than ternary ?: operator in JavaScript or not:
(process.env.RNS_E2E_AVD_NAME || isRunningCI)
    ? DEFAULT_CI_AVD_NAME
    : detectLocalAndroidEmulator();

or

process.env.RNS_E2E_AVD_NAME || (isRunningCI
    ? DEFAULT_CI_AVD_NAME
    : detectLocalAndroidEmulator());

?

  1. Why do we change this code at all here? From all I see we haven't started passing emulator name from CI through env, it is still hard coded name, therefore there is no need to change this code like that.

Copy link
Collaborator Author

@KrzysztofWojnar KrzysztofWojnar Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confess, I assumed we were going to pass this value all the time, but we used hardcoded CI_AVD_NAME as a fallback due to a misconfig 😅 but that part was fine all along. That's also the reason I touched those github configs.
I'm withdrawing this now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed with commit 3fbdad3

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and replaced with solution from e4074bd and 8c2044b

@KrzysztofWojnar KrzysztofWojnar force-pushed the @KrzysztofWojnar/e2e-config-for-detox-cleanup branch from c5fa206 to 3fbdad3 Compare November 21, 2025 19:31
@kkafar kkafar mentioned this pull request Nov 21, 2025
@kkafar
Copy link
Member

kkafar commented Nov 21, 2025

I've posted suggested review changes here: #3414

Comment on lines 14 to 15
const passedVersion = process.env.RNS_E2E_IOS_VERSION;
if (passedVersion) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that the passed version should have some specific format, so I'd add some documentation and additional validation that it matches the proper regex

Copy link
Collaborator Author

@KrzysztofWojnar KrzysztofWojnar Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration will be passed to Detox and I planned to rely on validation in Detox itself. However, now I think you're right, because for as long as I can remember, iPhones have had consistent naming conventions and I can expect them to maintain it.

const envVariableKey = 'RNS_E2E_IOS_VERSION';
const passedVersion = process.env[envVariableKey];
if (passedVersion) {
if (/^(iOS)\s.+/.test(passedVersion)) {
Copy link
Contributor

@t0maboro t0maboro Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I haven't made up my mind, but we'll have a rather fixed number of checks; therefore, I'm wondering if startsWith won't improve readability compared to a regex. Treat it as a nitpick; for me, it's okay to leave it in its current form.

const envVariableKey = 'RNS_E2E_APPLE_SIM_NAME';
const passedDevice = process.env[envVariableKey];
if (passedDevice) {
if (/^(iPhone|iPad)\s.+/.test(passedDevice)) {
Copy link
Contributor

@t0maboro t0maboro Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I haven't made up my mind, but we'll have a rather fixed number of checks; therefore, I'm wondering if startsWith won't improve readability compared to a regex. Treat it as a nitpick; for me, it's okay to leave it in its current form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants