Skip to content

Commit

Permalink
test: Improve E2E test consistency (#55554)
Browse files Browse the repository at this point in the history
* test: Mitigate conflicts between development server caches

Occasionally, cryptic npm package dependency errors can occur between
test runs. They appear to originate from stale development caches, e.g.
Metro server. Clearing these caches, which E2E tests should not rely
upon mitigates the likelihood of these errors.

* test: Prefix informative E2E test setup logs

Merely an attempt to add structure to the outputted logs.

* test: Avoid setup scripts during test runs

There may be clarity and efficiency by having an explicit setup script.
It was avoid running unnecessary scripts during test runs. It is also
referenced in the current documentation as a script to run
intentionally.
  • Loading branch information
dcalhoun authored Oct 24, 2023
1 parent b37ad19 commit 9d4613a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
~/.appium
key: ${{ runner.os }}-tests-setup-${{ hashFiles('package-lock.json') }}

- name: Prepare tests setup
run: npm run native test:e2e:setup

- name: Gradle cache
uses: gradle/gradle-build-action@b5126f31dbc19dd434c3269bf8c28c315e121da2 # v2.8.1

Expand Down
12 changes: 8 additions & 4 deletions packages/react-native-editor/bin/test-e2e-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ fi
output=$($APPIUM_CMD driver list --installed --json)

if echo "$output" | grep -q 'uiautomator2'; then
echo 'UiAutomator2 is installed, skipping installation.'
echo '[info] UiAutomator2 is installed, skipping installation.'
else
echo 'UiAutomator2 not found, installing...'
echo '[info] UiAutomator2 not found, installing...'
$APPIUM_CMD driver install uiautomator2
fi

if echo "$output" | grep -q 'xcuitest'; then
echo 'XCUITest is installed, skipping installation.'
echo '[info] XCUITest is installed, skipping installation.'
else
echo 'XCUITest not found, installing...'
echo '[info] XCUITest not found, installing...'
$APPIUM_CMD driver install xcuitest
fi

# Mitigate conflicts between development server caches and E2E tests
npm run clean:runtime > /dev/null
echo '[info] Runtime cache cleaned.'
4 changes: 2 additions & 2 deletions packages/react-native-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
"test:e2e:setup": "./bin/test-e2e-setup.sh",
"test:e2e:bundle:android": "mkdir -p android/app/src/main/assets && npm run rn-bundle -- --reset-cache --platform android --dev false --minify false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"test:e2e:build-app:android": "cd android && ./gradlew clean && ./gradlew assembleDebug",
"test:e2e:android:local": "npm run test:e2e:setup && npm run test:e2e:bundle:android && npm run test:e2e:build-app:android && TEST_RN_PLATFORM=android npm run device-tests:local",
"test:e2e:android:local": "npm run test:e2e:bundle:android && npm run test:e2e:build-app:android && TEST_RN_PLATFORM=android npm run device-tests:local",
"test:e2e:bundle:ios": "mkdir -p ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app && npm run bundle:ios && cp bundle/ios/App.js ./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle && cp -r bundle/ios/assets ./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/",
"test:e2e:build-app:ios": "npm run preios && ./bin/build_e2e_ios_app",
"test:e2e:build-wda": "xcodebuild -project ~/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ios/build/WDA",
"test:e2e:ios:local": "npm run test:e2e:setup && npm run test:e2e:bundle:ios && npm run test:e2e:build-app:ios && npm run test:e2e:build-wda && TEST_RN_PLATFORM=ios npm run device-tests:local",
"test:e2e:ios:local": "npm run test:e2e:bundle:ios && npm run test:e2e:build-app:ios && npm run test:e2e:build-wda && TEST_RN_PLATFORM=ios npm run device-tests:local",
"build:gutenberg": "cd gutenberg && npm ci && npm run build",
"clean": "npm run clean:build-artifacts; npm run clean:aztec; npm run clean:haste; npm run clean:metro; npm run clean:watchman",
"clean:runtime": "npm run clean:haste; npm run clean:metro; npm run clean:watchman; npm run clean:babel-cache",
Expand Down

0 comments on commit 9d4613a

Please sign in to comment.