We are using Jest and Appium to run the tests.
The file e2e-tests/native/capabilities.ts
contains the capability definitions. A set of capabilities is like a
requirement of devices you want to test against (e.g. Android 9/iOS 11).
Here is a good definition of capabilities and which
properties you can set.
Before first starting the test:
- make sure appium is installed by running
appium --version
- install appium android driver by running
appium driver install uiautomator2
in the project root. - set the APPIUM_HOME var to ~/.appium
- make sure everything is set up correctly:
appium driver list --installed
in the e2e-tests subfolder should list uiautomator2
- Start an emulator (only the emulator, don't need to manually start the app)
- Start the app:
yarn prepare:native:start
- Install the apk on the emulator:
yarn prepare:native:android
- Start the tests:
yarn test:native
-
Create an emulator with the settings from
wdio-ios.conf.ts
; if necessary, install the driver1.1. If the driver isn't available anymore, update the settings in the config file to a more recent one, ideally the ones from
e2e-tests/native/capabilities.ts
. -
Start the app:
yarn prepare:native:start
-
Find your build file folder: Product > Copy Build Folder Path
-
Add the BUILD_DIR to your environment. In zshell you do this via
BUILD_DIR=your/copied/build/folder/path; export BUILD_DIR
but your command line might differ. -
Run tests via
yarn test:native:ios
When writing tests, it may be helpful to use the (Appium Inspector)[https://github.com/appium/appium-inspector] to inspect the tree of the app.
- Download Appium Inspector from the releases
- Start an Appium server by running
appium
in command your line. Note the URLs your command line prints for accessing the server. - Fill one of those URLs into the host field. If you want to get to a specific route, fill in the path as well.
- Fill in keys and values of desired capabilities: deviceName, platformVersion, automationName, platformName. You
can find examples of those in the two files named
capabilities.ts
orwdio-ios.conf.ts
. - Click on "Start Session".
You can find your browserstack user
and key
here: https://app-automate.browserstack.com/
You can upload the app and give the upload a name by running:
curl -u "user:key" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/app/file/Application-debug.apk" \
-F "data={\"custom_id\": \"MyApp\"}"
From now on the upload will be called MyApp
. By re-uploading you are overwriting the file.
To run tests on browserstack environment like browserstack do:
E2E_CONFIG=browserstack_dev_android \
E2E_BROWSERSTACK_USER=user E2E_BROWSERSTACK_KEY=key E2E_BROWSERSTACK_APP=MyApp \
yarn test:e2e
Please note that there is a limit of concurrent tasks AND how many tasks can be queued. If you want to experiment
with this you can run jest with --maxWorkers=15
.
If you get complaints about missing env variable ANDROID_HOME, add it to the shell environment. In zshell, you to this
via ANDROID_HOME=~/Library/Android/sdk; export ANDROID_HOME
but your terminal might differ.
If you get lots of timeouts, start the app manually once on the emulator you want to use.
If you get a nasty-looking error when trying to open Appium Inspector on a Mac that says that Apple can't check it for malicious software and to contact the developer, try opening it by going to its location in Finder, right-clicking it > Open, you now get that error again. Click the error away and right-click again, then Open, you should now have a different warning that lets you open the app.
The API spec of wd can be found here and general information here.