Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 713
Toto NaBendo Avatar asked Nov 23 '25 16:11

Toto NaBendo


1 Answers

Detox is hard to setup/maintain over time.

With my react native apps i have migrated to maestro and it works like a charm.

  1. install it with
curl -fsSL "https://get.maestro.mobile.dev" | bash
  1. update your package.json
"scripts": {
  "e2e": "maestro test e2e/process.yaml"
}
  1. update your process.yaml
appId: host.exp.Exponent
---

- launchApp
- tapOn: "Email"
- inputText: "[email protected]"
- tapOn: "Password"
- inputText: "123456"
- tapOn: "Login"

or you can launch from your terminal

maestro studio

to visually write your script.

like image 108
David Leuliette Avatar answered Nov 26 '25 05:11

David Leuliette



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!