It is reccomended these tests be run from a terminal prompt with unlimited lines of scroll-back.
Instructions for iTerm2: open Preferences -> open "Profiles" tab -> your profile -> "Terminal" sub top-bar tab -> check ✓ "Unlimited Scrollback"
-
Follow main repo install instructions
-
then, from a shell open in the repo run:
brew tap wix/brew && brew install applesimutils
-
be sure the project builds in Xcode
- Get yourself one or more emulators, you have options:
- Detox recommends Android Open-Source Project (AOSP) emulators
- Install from Android Studio with these instructions
- (Optional) Set up quick boot on the emulator.
NOTE: The AOSP emulators appear to require Java 8 (JDK 1.8). You may have a newer version of Java, like Java 15 installed...
IMPORTANT JAVA NOTICE
Instructions on how to install older versions of Java alongside modern Java versions, and how to easily switch between them: -> java.md <-
outilned in .detoxrc.json
A shared test that gets through onboarding. Used before other tests to get deeper into the app.
Staging app build only: iterates through every page of the app using the debug menu, taking screenshots as it goes. Find the output in artifacts
folder.
Useful scripts that parse test output to produce image galleries and easily shareable PDFs. See the test-gallery/README.md
The following commands will run a Detox build. This need to be re-run whenever logic changes are made to the app.
yarn pre:test:android
or
yarn pre:test:ios
Metro server must be running for Detox to interact with the app. You might not have a metro server running if you haven't recently run yarn pre:test:ios
, or if you've run it, but closed the many prompts it opens.
From a separate terminal tab, or prompt, navigate to the app repo and run yarn start
(an alias for npx react-native start
)
BUNDLE BUILDING TAKES TIME -> see progress bar indicator at bottom of Metro server window.
From a command prompt at the main repo directory, executing, for example:
detox test e2e/exploreDemoMenu.e2e.js --configuration=ios
will load the simulator and run that particular test
or use --configuration=android.aosp
to test using the android AOSP simulator.
A succesful run of this test will look like follows:
This test ran in 100 seconds on a 2017, 13-inch Macbook Pro laptop.
This may take several minutes, and heavily uses computer resources while running.
Executing either
yarn test:android
or
yarn test:ios
from the root fo the project will execute all .e2e.js
tests containted in the /e2e
folder. They are all run in parallel by Jest, and thus order of execution is not guaranteed.
Sorted by "deeper into the rabbit hole":
You may dismiss warnings, and they should go away for the lifetime of the simulator. However...
Important: If Errors pop up they will overlap the visual items the simulator is trying to show, and thus block the items below them. If your issues persist, please file an Issue on Github to see if the error(s) can be remedied or handled differently.
This is a common fault, for example, at Onboarding from background checks failing to preoperly execute in the simulator...
Many things can cause builds to fail. Basically, the app must succesfully build in Xcode, deploy to and open the simulator in Xcode (or with yarn run-ios
), otherwise Detox builds won't work... but here are some things to try:
- Open the app project in Xcode
- (optional) NavBar -> Product -> Clean Build Folder (accept to kill any running instances)
- navigate throught Left Sidebar -> Folder Icon -> click on "CovidShield" project -> opens -> middle top tab "Signing & Capabilities" -> middle lower top tab "Debug" -> collapsible section "Signing" -> dropdown "Provisionning Profile" -> make sure no errors here...
- Top bar -> ensure Active Scheme set to "Staging"
- Top bar -> ensure Target Device set to preferred simulator (iPhone 8 reccomended)
> xcodebuild: error: The workspace named "CovidShield" does not contain a scheme named "SchemeName".
The Xcode build schema was changed and needs to be updated in .detoxrc.json
.
- Open the app project in Android Studio
- You likely have updates pending, apply them all.
- Top bar -> Build project
Project must succesfully build in Android Studio, otherwise it'll never work on the command-line...
just run the test once more... this is pretty common.
> Test Failed: No views in hierarchy found matching: (with tag value: is "someTagName"
this means one test item is looking for an HTML-like item with a tag/attribute of the name "someTagName", and is not finding it. Most likely a swipe/scroll handle not set (by the devs) in a newly made "SomethingView.tsx".
> Task :@react-native-community_async-storage:processDebugAndroidTestResources FAILED
you can try: cd android && ./gradlew clean