detox-tools icon indicating copy to clipboard operation
detox-tools copied to clipboard

Workaround for Detox with Dev-Client

Open enesozturk opened this issue 4 years ago • 5 comments

Hi, I have been working on a setup of e2e tests with Detox in my app that uses Expo Dev Client. I've found some docs and issues with the Expo-based apps but cannot figure it out with the Dev Client and got some issues.

  • On the first try, I configured Detox as expected and it builds & launches my app to run tests but when Detox opens the app, the Expo dev launcher appears, (probably) that is why Detox cannot detect it and cannot run the tests successfully.
    • Looked for a way to disable dev-launcher but couldn't found. Manually disabled it in AppDelegate.m and built it, I was able to run the app in debug mode. But when I run the detox tests, it tries to run tests without opening the app.
  • Then I found your article, followed the steps, and installed the helper packages both expo-detox-hook and detox-expo-helpers, (not sure if they are for the apps dev-client (not fully Expo)). But this time Detox is running the tests without opening the app. And failing as a result.
    • Found this issue and also tried with the changes suggested, no result.

Any workaround with the apps with Dev Launcher? Not sure which side is this issue related to. Thanks in advance.

Sources:

  • https://github.com/wix/detox/blob/master/docs/Introduction.GettingStarted.md
  • https://blog.expo.dev/testing-expo-apps-with-detox-and-react-native-testing-library-7fbdbb82ac87
  • https://github.com/expo/detox-tools/issues/1

enesozturk avatar Apr 18 '22 09:04 enesozturk

for me it helped to use following code in beforeAll in test to open the app on the specific server. Now I only need to close dev menu and I would be good to go: await device.openURL({ url: exp+<app-slug>://expo-development-client/?url=${encodeURIComponent( http://localhost:8081 )}, });

credit for this https://medium.com/@Nicomalacho/e2e-tests-with-expo-development-client-b6c95b0678b3

MCervenka avatar Jul 08 '24 09:07 MCervenka

For those who are having trouble closing dev menu for the first time launch: -After using device.openURL() we can use device.shake() to hide the DevMenu (wasn't explained anywhere 😢 )

kyaroru avatar Sep 13 '24 04:09 kyaroru