平台

Android setup

Get this machine ready to test an Expo, React Native or native Android app on an emulator with danwo.

本页还没有中文版,下面是英文原文。

danwo runs the same tests, invariants and fault matrix against an Android app on an emulator: an Expo or React Native app, or a native one written with Jetpack Compose or Views. The app's calls go through danwo's proxy, so Stripe and the rest are emulated there too. One package, @danwo/mobile, builds your app so it trusts danwo, then runs it on a simulator or emulator. This page gets the machine ready.

What you need

NeedWhy
Android Studioit brings the Android SDK (adb, the emulator) and a JDK
a Google APIs system imagedanwo needs root to trust its certificate; Play Store images can't be rooted
an AVDthe virtual device danwo boots

Create the emulator

Install Android Studio

Install it, open it once, and let it download the SDK.

Add a Google APIs image

In Device Manager, create a device and pick a system image whose target says Google APIs, not Google Play. On Apple silicon use arm64-v8a; on Intel and Linux, x86_64:

system-images;android-34;google_apis;arm64-v8a

Name the AVD

Give it a short name, such as danwo_spike. Your config refers to it by that name.

Add the mobile package

danwo init adds @danwo/mobile when tests drive Mobile or Web and mobile. To add it to a project set up for the web, install it. It must be the same version as @danwo/cli, so name that version if yours is not the latest:

npm install -D @danwo/mobile

Without it, the mobile commands stop and name that install:

danwo device doctor needs @danwo/mobile: npm install -D @danwo/[email protected]

Check the machine

npx @danwo/cli device doctor --platform android
ok    Android SDK: ~/Library/Android/sdk
ok    adb: ~/Library/Android/sdk/platform-tools/adb
ok    emulator: ~/Library/Android/sdk/emulator/emulator
ok    system images: rootable: system-images/android-34/google_apis/arm64-v8a
ok    AVD danwo_spike: system-images/android-34/google_apis/arm64-v8a
ok    JDK: /Applications/Android Studio.app/Contents/jbr/Contents/Home

Each line is ok, warn or a failure with what to do. It also warns about an emulator left with a proxy setting from an earlier run, and about images missing their files.

In a project whose config calls withAndroidDevice, npx @danwo/cli doctor runs these checks too.

Apps that pin their TLS certificates ignore danwo's certificate, so their calls can't be emulated. Turn pinning off in the build you test.

What works on Android today

WorksNot yet
Expo, React Native, Compose and Views appstests on a Flutter app, which only builds so far
locators, expect, screenshots, the agenthover, setInputFiles, dragTo
Custom Tabs (a web checkout inside the app)reading mail from a test, saved sessions
the fault matrix, on one emulator or severalmoving the device's own clock
time travel for your services and backend

Next

本页内容

在每个 Pull Request 上运行

每个 Pull Request 一个 GitHub Check 和一条评论,并附上完整的运行记录。

配置 CI