From 87f51bebc108ffaf0e04c27627c43c7356ed6092 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Fri, 27 Oct 2023 13:57:28 -0400 Subject: [PATCH] test: iOS E2E tests set OS version (#55661) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: iOS E2E tests set OS version Without setting this, cryptic errors result where Xcode may attempt to build the app for the local development machine, rather than the targeted iOS simulator. ``` ** BUILD FAILED ** ❌ gutenberg/packages/react-native-editor/ios/GutenbergDemo.xcodeproj: Provisioning profile "Gutenberg Development" doesn't include the currently selected device "MacBook Pro" (identifier [REDACTED]). (in target 'GutenbergDemo' from project 'GutenbergDemo') ``` * docs: Fix incorrect E2E test example scripts The nested npm script requires additional `--` separators to pass the argument to the resulting Jest command. --- packages/react-native-editor/__device-tests__/README.md | 6 +++++- packages/react-native-editor/bin/build_e2e_ios_app | 2 +- packages/react-native-editor/package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/README.md b/packages/react-native-editor/__device-tests__/README.md index e9e85312c3f1ee..8d9ce47b6cc9fa 100644 --- a/packages/react-native-editor/__device-tests__/README.md +++ b/packages/react-native-editor/__device-tests__/README.md @@ -70,7 +70,7 @@ You can filter which test runs by one of two ways: npm run native test:e2e:ios:local gutenberg-editor-paragraph.test.js # Enable watch mode on iOS -npm run native test:e2e:ios:local -- --watch +npm run native test:e2e:ios:local -- -- -- --watch ``` ## Speeding Up Test Runs @@ -90,7 +90,11 @@ While we must run all of these at least once to produce a testable app, it is of By default `device-tests:local` runs tests for Android. To run tests on iOS, you can prefix the script with the `TEST_RN_PLATFORM` environment variable. ```shell +# Run tests on iOS TEST_RN_PLATFORM=ios npm run native device-tests:local + +# Run tests on iOS with watch mode enabled +TEST_RN_PLATFORM=ios npm run native device-tests:local -- -- --watch ``` ## Debugging Tests diff --git a/packages/react-native-editor/bin/build_e2e_ios_app b/packages/react-native-editor/bin/build_e2e_ios_app index 6a5a57d5a69ebe..569a62db21097f 100755 --- a/packages/react-native-editor/bin/build_e2e_ios_app +++ b/packages/react-native-editor/bin/build_e2e_ios_app @@ -2,7 +2,7 @@ set -o pipefail -DEFAULT_DESTINATION='platform=iOS Simulator,name=iPhone 14' +DEFAULT_DESTINATION='platform=iOS Simulator,name=iPhone 14,OS=16.2' if [[ -z "${RN_EDITOR_E2E_IOS_DESTINATION-}" ]]; then DESTINATION="$DEFAULT_DESTINATION" else diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index d473538a354ba8..ccc7f64d1f7bca 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -115,7 +115,7 @@ "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 14' -derivedDataPath ios/build/WDA", + "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 14,OS=16.2' -derivedDataPath ios/build/WDA", "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",