1## E2E test setup 2 3To run the updates e2e tests locally, do the following: 4 5- Create a script to set up the environment and remove any previous build, as in the example below. 6 7```bash 8# The location of your local copy of this repo 9export EXPO_REPO_ROOT=/Users/me/myCode/expo 10# The name of a directory that the test project can live under 11export WORKING_DIR_ROOT=/Users/me/myCode/e2eworking 12# Other environment variables needed for the test setup 13export TEST_PROJECT_ROOT=$WORKING_DIR_ROOT/updates-e2e 14export UPDATES_HOST=localhost 15export UPDATES_PORT=4747 16export EX_UPDATES_NATIVE_DEBUG=1 17 18# Remove and recreate the working directory before executing the setup 19rm -rf $WORKING_DIR_ROOT 20mkdir $WORKING_DIR_ROOT 21``` 22 23- From the Expo repo root directory, execute 24 25```bash 26node packages/expo-updates/e2e/setup/create-eas-project.js 27``` 28 29- Change to the `TEST_PROJECT_ROOT` location above. 30 31- Execute 32 33``` 34yarn generate-test-update-bundles 35``` 36 37- To run iOS tests: 38 39 - Start an iPhone 14 simulator 40 - Execute these commands: 41 42```bash 43npx pod install 44yarn detox:ios:debug:build 45yarn detox:ios:debug:test 46``` 47 48- To run Android tests: 49 50 - Ensure you have an emulator running named `pixel_4` (or change `.detoxrc.json` to use the name of your own running emulator) 51 - Execute `adb reverse tcp:4747 tcp:4747` to ensure that the test server is accessible 52 - Then run 53 54```bash 55yarn detox:android:release:build 56yarn detox:android:release:test 57``` 58 59- Running in your own EAS space: 60 61Edit `app.json` and remove the `extra` section with the EAS project ID, then execute 62 63```bash 64eas init 65eas build --profile=updates_testing --platform=<android|ios> 66``` 67 68- Testing the EAS build locally: 69 70 - Ensure you have an emulator running named `pixel_4` 71 - Make the change below in `eas.json`: 72 73```diff 74--- a/packages/expo-updates/e2e/fixtures/project_files/eas.json 75+++ b/packages/expo-updates/e2e/fixtures/project_files/eas.json 76@@ -15,7 +15,8 @@ 77 "updates_testing": { 78 "env": { 79 "EX_UPDATES_NATIVE_DEBUG": "1", 80- "NO_FLIPPER": "1" 81+ "NO_FLIPPER": "1", 82+ "LOCAL_TESTING": "1" 83 }, 84 "android": { 85 "gradleCommand": ":app:assembleRelease :app:assembleAndroidTest -DtestBuildType=release", 86``` 87 88 - Clone the `eas-build` repo, and build it (`yarn`, `yarn build`) 89 - Set up the local EAS build environment as in this example: 90 91``` 92#!/usr/bin/env bash 93 94export EAS_LOCAL_BUILD_HOME=<the eas-build directory that you just cloned above> 95 96export EAS_LOCAL_BUILD_PLUGIN_PATH=$EAS_LOCAL_BUILD_HOME/bin/eas-cli-local-build-plugin 97export EAS_LOCAL_BUILD_WORKINGDIR=$TMPDIR/eas-build-workingdir 98export EAS_LOCAL_BUILD_SKIP_CLEANUP=1 99export EAS_LOCAL_BUILD_ARTIFACTS_DIR=$TMPDIR/eas-build-workingdir/results 100 101rm -rf $EAS_LOCAL_BUILD_WORKINGDIR 102``` 103 104 - Execute 105 106```bash 107eas init 108eas build --profile=updates_testing --platform=<android|ios> --local 109``` 110 111## Updates API test project: 112 113This creates a test project that allows you to exercise the Updates API features manually against EAS. The project is set up to use `expo-channel-name=main` as the EAS update request header. 114 115- Execute this to set up the environment: 116 117```bash 118# The location of your local copy of this repo 119export EXPO_REPO_ROOT=/Users/me/myCode/expo 120# The name of a directory that the test project can live under 121export WORKING_DIR_ROOT=/Users/me/myCode/e2eworking 122# The user name of the Expo account you are logged into 123export EXPO_ACCOUNT_NAME=myexpoaccount 124# Other environment variables needed for the test setup 125export TEST_PROJECT_ROOT=$WORKING_DIR_ROOT/MyUpdatesApp 126export EX_UPDATES_NATIVE_DEBUG=1 127 128# Remove and recreate the working directory before executing the setup 129rm -rf $WORKING_DIR_ROOT 130mkdir $WORKING_DIR_ROOT 131``` 132 133- Then execute 134 135```bash 136node packages/expo-updates/e2e/setup/create-updates-test.js 137``` 138 139- Change to the test project directory 140 141- Execute these commands to set up EAS: 142 143```bash 144eas init 145eas update:configure 146``` 147 148- Build and run the project locally 149 150```bash 151npx pod-install # if testing iOS 152npx expo run:<ios|android> 153``` 154 155- To create an update, just execute `eas update` and select the default branch (`main`) and default commit message. 156- To detect the update on the client, just restart the client, or press the "Check for update manually" button 157- If there is an update, the "Download and run update" button will appear, and pressing it will load and launch the update. 158