Detox support on SDK 37+?

I have not been able to successfully integrate Detox with Expo on either SDK37 or 38. When launching the Detox process with iOS, Expo is reinstalled onto the sim, but the app does not launch – so the tests timeout on the Expo landing pad.

The most up-to-date online example appears to no longer work as of Nov 2019: https://github.com/yaron1m/expo-detox-typescript-example/issues/5

Has anyone had success running Detox on newer Expo versions? Failing that – is there any other way to perform E2E UI testing on Expo right now? Thanks.

Hey @scjohnson16,

Detox should work but you can’t use the standard Expo Client. You’ll have to build a simulator build for iOS via expo bi -t simulator and an apk for android via expo ba -t apk. We don’t currently have this documented anywhere but we plan on adding a section to help users who want to use Detox.

Cheers,
Adam

7 Likes

Thanks! It should be noted that you’ll need to reference the path to the extracted app file within the detox sim config’s binaryPath.

2 Likes

Thanks for the additional insight! We’ll make sure to add that to our guide.

Thanks both of you for throwing me a bone! My team doesn’t quite have time to wait for the expo to write a guide so we would be greatly appreciate if either of you could briefly summarize the steps we’d need to take to set up detox with expo. Hell, if we figure it out we could write the guide ourselves. I’ve personally tried a few of approaches and regardless of which approach i choose it ultimately leads me into a rabbit hole of trying to debug/understand big codebases that I’m unfamiliar with.

EDIT: Just determined the issue is actually some sort of synchronization issue with our app. I had incorrectly assumed that expo was not playing well with detox. Rather, detox is waiting on some action in our app to finish indefinitely. Would still be happy to write the expo + detox guide to save others from this headache. @adamjnav please let me know if this is something that the team has already started internally and if not I’ll submit a pr.

1 Like

Would love to see any version of this guide too! @adamjnav @ramicaza . Right now i’m deep in that rabbit hole.

Also Adam. If you use expo ba -t apk for the simulator build then how do you sync up the signing of the test apk.

Thanks for the info! Here’s what my Detox config looks like so far:

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "configurations": {
    "ios": {
      "type": "ios.simulator",
      "binaryPath": "myapp.app",
      "build": "expo bi -t simulator && curl -o app.tar.gz \"$(expo url:ipa --non-interactive)\" && tar -xzf app.tar.gz && rm app.tar.gz",
      "device": {
        "type": "iPhone 11"
      }
    },
    "android": {
      "type": "android.emulator",
      "binaryPath": "app.apk",
      "build": "expo ba -t apk && curl -o app.apk \"$(expo url:apk --non-interactive)\"",
      "device": {
        "avdName": "Nexus_5X_API_29_x86"
      }
    }
  }
}

I got Detox working with iOS, but for Android I get this error:
detox[38852] ERROR: Error: '/Users/myuser/androidTest/app/app-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest'?

2 Likes

I have the same issue with Android. Did you ever figure this out?

UPDATE: I set testBinaryPath to the same value I had for binaryPath. That got rid of that error, but now I’m getting the error
Error: Failed to parse APK file: /data/local/tmp/detox/Application.apk

I created an APK with expo ba -t apk and configured Detox to use the APK. However, I get the following error when running detox test:

detox[21220] INFO:  [test.js] useCustomLogger=true forceAdbInstall=false DETOX_START_TIMESTAMP=1606358311583 readOnlyEmu=false reportSpecs=true jest --config e2e/config.json --testNamePattern "^((?!:ios:).)*$" --maxWorkers 1 e2e
detox[30708] INFO:  [DetoxServer.js] server listening on localhost:60269...
detox[30708] INFO:  at node_modules\detox\src\devices\drivers\android\exec\ADB.js:248:13
 { instrumentationRunners: '', bundleId: 'com.dstaley.kintorn' }
detox[30708] ERROR: Error: No instrumentation runner found on device emulator-5554 for package com.dstaley.kintorn

I can confirm this by running adb shell pm list instrumentation, which returns no output.

@adamjnav Any ideas what I might be missing here?