Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Detox Transition in Expo Environment #4292

Open
alexferreira1796 opened this issue Nov 28, 2023 · 5 comments
Open

Issue with Detox Transition in Expo Environment #4292

alexferreira1796 opened this issue Nov 28, 2023 · 5 comments

Comments

@alexferreira1796
Copy link

Description

Hello,

I'm encountering a specific issue while using Detox in conjunction with Expo SDK 48.0.0. Upon attempting to transition to the next screen after tapping a button, the test doesn't proceed as expected. This inconsistent behavior occurs only in the test environment, whereas the simulator operates correctly.

The app is busy with the following tasks:
• Run loop "Main Run Loop" is awake.
• The event "Gesture Recognizer" is taking place with object: "<LROTouchShim: 0x1055599f0; baseClass = UIGestureRecognizer; state = Possible; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = <UIWindow: 0x105527920>>".
• There are 1 work items pending on the dispatch queue: "Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)".

Captura de Tela 2023-11-28 às 17 15 08

This looping persists until it exceeds the 120000ms timeout.

Test Code:

it('should navigate to registration screen when clicking the "Start now" button', async () => {
    const buttonStartNow = element(by.text('Start now'));
    await expect(buttonStartNow).toBeVisible();
    await buttonStartNow.tap();
});

Welcome Screen Button:
<Button testID="btnregister" text="Start now" path="Register" />

Button Component:

const navigation = useNavigation();
<TouchableOpacity
    testID={testID}
    onPress={() => navigation.navigate(path)}
>
    <Text>Start now</Text>
</TouchableOpacity>

What could I do to fix it?

Thank you in advance for your attention and support in resolving this issue.

Your environment

Detox Version: 20.13.5
Expo SDK: 48.0.0
Operating System: macOS M1 Sonoma 14.1.1
Node: 18.16
Device Model: iPhone 15

@noomorph
Copy link
Collaborator

@asafkorem again GestureHandler strikes back. 😅

@ph0lcidae
Copy link

Came to file an almost identical issue and hopefully offer some more diagnostic info instead of filing a duplicate:

I'm seeing nearly the same thing:

The app is busy with the following tasks:
• There are 1 work items pending on the dispatch queue: "Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)".
• The event "Gesture Recognizer" is taking place with object: "<LROTouchShim: 0x7fb2e9d21410; baseClass = UIGestureRecognizer; state = Possible; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = <UIWindow: 0x7fb2e8fa0940>>".
• Run loop "Main Run Loop" is awake.

Test code snip:

  async clickSignInButton() {
    await element(by.id(TestConstants.WELCOME_SIGN_IN_BUTTON)).tap();
  }

  async setEmail(email) {
    await element(by.id(TestConstants.EMAIL_FIELD)).typeText(email);
  }

On app launch, Detox is able to tap the sign-in button in our app, but on page transition to fill fields or click other buttons, it hangs waiting for GestureRecognizer and eventually times out. If I manually intervene to tap the text field in the simulator, Detox will fill it and continue with any other gestures/actions on the same screen, but when the app transitions to a new screen, Detox is stuck waiting again.

This is only an issue when pointing my app at our development API (which requires external network requests); if I point it at an instance of our API running locally (no external network requests), Detox has no issues navigating the app. I'm not sure if it's related (it doesn't seem like anything Detox would involve itself with?) but felt it might be worth a mention considering it's the only variant factor.

It works if I use disableSynchronization();, but that's not ideal.

I know y'all don't support Expo, but I'm not sure Expo is the issue here given it works fine when there isn't an external network call involved.

Thank you for your time!


Detox version: 20.13.5
Expo SDK: 48.0.21
OS: macOS M1 Ventura 13.5
Node: 16.16
Device: iPhone 15 / iOS 17

@alexferreira1796
Copy link
Author

Vim registrar um problema quase idêntico e, com sorte, oferecer mais informações de diagnóstico em vez de registrar uma duplicata:

Estou vendo quase a mesma coisa:

The app is busy with the following tasks:
• There are 1 work items pending on the dispatch queue: "Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)".
• The event "Gesture Recognizer" is taking place with object: "<LROTouchShim: 0x7fb2e9d21410; baseClass = UIGestureRecognizer; state = Possible; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = <UIWindow: 0x7fb2e8fa0940>>".
• Run loop "Main Run Loop" is awake.

Recorte de código de teste:

  async clickSignInButton() {
    await element(by.id(TestConstants.WELCOME_SIGN_IN_BUTTON)).tap();
  }

  async setEmail(email) {
    await element(by.id(TestConstants.EMAIL_FIELD)).typeText(email);
  }

Ao iniciar o aplicativo, o Detox é capaz de tocar no botão de login em nosso aplicativo, mas na transição da página para preencher campos ou clicar em outros botões, ele fica esperando GestureRecognizere eventualmente expira. Se eu intervir manualmente para tocar no campo de texto no simulador, o Detox irá preenchê-lo e continuar com quaisquer outros gestos/ações na mesma tela, mas quando o aplicativo faz a transição para uma nova tela, o Detox fica parado esperando novamente.

Isso só é um problema ao apontar meu aplicativo para nossa API de desenvolvimento (que requer solicitações de rede externa); se eu apontar para uma instância de nossa API em execução localmente (sem solicitações de rede externa), o Detox não terá problemas para navegar no aplicativo. Não tenho certeza se está relacionado (não parece nada com que o Detox se envolveria?), Mas achei que valeria a pena mencionar, considerando que é o único fator variante.

Funciona se eu usar disableSynchronization();, mas não é o ideal.

Eu sei que vocês não apoiam a Expo, mas não tenho certeza se a Expo é o problema aqui, pois funciona bem quando não há uma chamada de rede externa envolvida.

Obrigado pelo seu tempo!

Versão Detox: 20.13.5 Expo SDK: 48.0.21 SO: macOS M1 Ventura 13.5 Nó: 16.16 Dispositivo: iPhone 15 / iOS 17

Try using the iPhone 12 Pro Max version
I managed to get the tests to run on this version

@ph0lcidae
Copy link

In case it's helpful to anyone else: for us, this turned out to be an issue with LogRocket - not sure exactly what it's doing under the hood, but it seems to be hogging UI resources so Detox waits forever (I imagine that's what LROTouchShim is). Disabling LogRocket fixed it.

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

@stale stale bot added the 🏚 stale label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants