Wednesday, 30 June 2021

Setting up Detox with Expo on Android

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


from Setting up Detox with Expo on Android

No comments:

Post a Comment