12

I'm trying to set up Detox with Expo on Android emulator (Genymotion) but I have an error that I can't go through....

I've installed the necessary packages :

  • Detox
  • detox-expo-helpers
  • expo-detox-hook

Downloaded the Exponent.apk on the official expo site

set up my package.json :

"detox": {
    "test-runner": "jest",
    "configurations": {
      "android": {
        "binaryPath": "bin/Exponent.apk",
        "build": "npm run android",
        "type": "android.attached",
        "device": {
          "adbName": "192.168.58.101:5555"
        }
      }
    }
  }

Set up the config.json on the e2e folder :

{
    "setupFilesAfterEnv": ["./init.ts"],
    "testEnvironment": "node",
    "reporters": ["detox/runners/jest/streamlineReporter"],
    "verbose": true
}

Set up my init.ts file :

import {cleanup, init} from "detox";
import * as adapter from "detox/runners/jest/adapter";

const config = require("../package.json").detox;

jest.setTimeout(120000);
jasmine.getEnv().addReporter(adapter);

beforeAll(async () => {
    await init(config);
});

beforeEach(async () => {
    await adapter.beforeEach();
});

afterAll(async () => {
    await adapter.afterAll();
    await cleanup();
});

When I run the tests with detox test I've the following error :

Error: '.../androidTest/Exponent/Exponent-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest' ?

How is generated this androidTest file with Expo ? Did I made something wrong ?

EDIT :

I've also try to use the .sh script to fetch the Exponent.apk file :

#!/bin/bash -e

# query expo.io to find most recent ipaUrl
IPA_URL=`curl https://expo.io/--/api/v2/versions |  python -c 'import sys, json; print json.load(sys.stdin)["androidUrl"]'`

# download tar.gz
TMP_PATH=bin/Exponent.apk
wget -O $TMP_PATH $IPA_URL
Toto NaBendo
  • 317
  • 1
  • 19
  • Hi, did you follow exactly the steps on : https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md? – loic.lopez Feb 07 '20 at 08:20
  • I'm using expo, so I don't have a gradle file... – Toto NaBendo Feb 07 '20 at 08:40
  • yes missed that, did you follow a tutorial like: https://blog.expo.io/testing-expo-apps-with-detox-and-react-native-testing-library-7fbdbb82ac87 – loic.lopez Feb 07 '20 at 08:41
  • 1
    It works only on iOS emulator... :( Would like to make it on android emulator – Toto NaBendo Feb 07 '20 at 09:02
  • I think if you really want to run on android emulator try to migrate your project to a raw react-native project an follow the installation from the Detox get started – loic.lopez Feb 07 '20 at 09:04
  • Did you actually run `detox build` – Black Apr 16 '20 at 17:09
  • @Black there is no build command for the Expo setup. OP can you share what you have for iOS as mine is not running the tests in the emulator it eventually times out. Would appreciate if you could share. – Sigex Feb 03 '21 at 12:46

0 Answers0