Repository: wix/Detox
Pull request #3921 (2023-02-09 09:38:05)

React Native 70 compliance - Detox test project
## Description

<!--
Thank you for contributing!

Step 1: Before submitting a pull request that introduces a new functionality or fixes a bug,
please open an issue where we could discuss the suggestion, problem - and potential ways to fix.
-->

- This pull request #3735

<!--
Step 2: Provide an overview of how your fix / enhancement works.
If possible, provide screenshots of the before and after states (even for simple command line options - show the terminal).
-->

In this pull request, I have made the necessary changes in order to assert compliance with RN .70 in the main test-proejct, (mostly) based on https://react-native-community.github.io/upgrade-helper/?from=0.69.7&to=0.70.7 .

<!--
Step 3: Please review the checklist below.
-->

---


> _For features/enhancements:_
 - [ ] I have added/updated the relevant references in the [documentation](https://github.com/wix/Detox/tree/master/docs) files.

> _For API changes:_
 - [ ] I have made the necessary changes in the [types index](https://github.com/wix/Detox/blob/master/detox/index.d.ts) file.



Patch:
diff --git a/.buildkite/jobs/pipeline.android_rn_69.yml b/.buildkite/jobs/pipeline.android_rn_70.yml
similarity index 78%
rename from .buildkite/jobs/pipeline.android_rn_69.yml
rename to .buildkite/jobs/pipeline.android_rn_70.yml
index dcaab7d9e..0ec71234c 100644
--- a/.buildkite/jobs/pipeline.android_rn_69.yml
+++ b/.buildkite/jobs/pipeline.android_rn_70.yml
@@ -1,9 +1,9 @@
-  - label: ":android::detox: RN.69 + Android: Tests app"
+  - label: ":android::detox: RN .70 + Android: Tests app"
     command:
       - "nvm install"
       - "./scripts/ci.android.sh"
     env:
-      REACT_NATIVE_VERSION: 0.69.7
+      REACT_NATIVE_VERSION: 0.70.7
       DETOX_DISABLE_POD_INSTALL: true
       DETOX_DISABLE_POSTINSTALL: true
       SKIP_UNIT_TESTS: true
diff --git a/.buildkite/jobs/pipeline.ios_rn_69.yml b/.buildkite/jobs/pipeline.ios_rn_70.yml
similarity index 73%
rename from .buildkite/jobs/pipeline.ios_rn_69.yml
rename to .buildkite/jobs/pipeline.ios_rn_70.yml
index 43e8dcbb1..6f1bdac33 100644
--- a/.buildkite/jobs/pipeline.ios_rn_69.yml
+++ b/.buildkite/jobs/pipeline.ios_rn_70.yml
@@ -1,9 +1,9 @@
-  - label: ":ios::detox: RN.69 + iOS: Tests app"
+  - label: ":ios::detox: RN .70 + iOS: Tests app"
     command:
       - "nvm install"
       - "./scripts/ci.ios.sh"
     env:
-      REACT_NATIVE_VERSION: 0.69.7
+      REACT_NATIVE_VERSION: 0.70.7
     artifact_paths:
       - "/Users/builder/work/coverage/**/*.lcov"
       - "/Users/builder/work/allure*.tar.gz"
diff --git a/.buildkite/pipeline.debug.yml b/.buildkite/pipeline.debug.yml
index 6326191c5..eab3359be 100644
--- a/.buildkite/pipeline.debug.yml
+++ b/.buildkite/pipeline.debug.yml
@@ -14,8 +14,8 @@ steps:
             value: "ios_rn_69"
           - label: "Android RN 68"
             value: "android_rn_68"
-          - label: "Android RN 69"
-            value: "android_rn_69"
+          - label: "Android RN 70"
+            value: "android_rn_70"
           - label: "Android Demo App RN 68"
             value: "android_demo_app_rn_68"
           - label: "Android Demo App RN 69"
diff --git a/.buildkite/pipeline_common.sh b/.buildkite/pipeline_common.sh
index bafe01f2f..b4875d7e1 100755
--- a/.buildkite/pipeline_common.sh
+++ b/.buildkite/pipeline_common.sh
@@ -3,9 +3,9 @@
 echo "steps:"
 
 cat .buildkite/jobs/pipeline.ios_rn_68.yml
-cat .buildkite/jobs/pipeline.ios_rn_69.yml
+cat .buildkite/jobs/pipeline.ios_rn_70.yml
 cat .buildkite/jobs/pipeline.android_rn_68.yml
-cat .buildkite/jobs/pipeline.android_rn_69.yml
+cat .buildkite/jobs/pipeline.android_rn_70.yml
 cat .buildkite/jobs/pipeline.android_demo_app_rn_68.yml
 cat .buildkite/jobs/pipeline.android_demo_app_rn_69.yml
 cat .buildkite/jobs/pipeline.ios_demo_app_rn_68.yml
diff --git a/detox/package.json b/detox/package.json
index 20682fafd..7689d1490 100644
--- a/detox/package.json
+++ b/detox/package.json
@@ -51,7 +51,7 @@
     "jest-allure2-reporter": "^1.2.1",
     "mockdate": "^2.0.1",
     "prettier": "1.7.0",
-    "react-native": "0.69.7",
+    "react-native": "0.70.7",
     "react-native-codegen": "^0.0.8",
     "typescript": "^4.5.2",
     "wtfnode": "^0.9.1"
@@ -199,4 +199,4 @@
       }
     }
   }
-}
+}
\ No newline at end of file
diff --git a/website/package.json b/website/package.json
index 3635395c4..8116d8af5 100644
--- a/website/package.json
+++ b/website/package.json
@@ -15,10 +15,10 @@
     "write-heading-ids": "docusaurus write-heading-ids"
   },
   "dependencies": {
-    "@docusaurus/core": "^2.2.0",
-    "@docusaurus/preset-classic": "^2.2.0",
-    "@docusaurus/remark-plugin-npm2yarn": "^2.2.0",
-    "@docusaurus/theme-search-algolia": "^2.2.0",
+    "@docusaurus/core": "^2.3.1",
+    "@docusaurus/preset-classic": "^2.3.1",
+    "@docusaurus/remark-plugin-npm2yarn": "^2.3.1",
+    "@docusaurus/theme-search-algolia": "^2.3.1",
     "@mdx-js/react": "^1.6.21",
     "@percy/cli": "^1.17.0",
     "@svgr/webpack": "^5.5.0",
diff --git a/website/percy.mjs b/website/percy.mjs
index b610d1564..58772e844 100644
--- a/website/percy.mjs
+++ b/website/percy.mjs
@@ -68,10 +68,21 @@ class Server {
   }
 }
 
+async function runPercySnapshot() {
+  const { stdout } = await $`percy snapshot snapshots.yml`;
+  const [, buildId] = stdout.match(/Finalized build #(\d+):/m) || [];
+  return buildId || '';
+}
+
 const server = new Server();
 try {
   await server.start();
-  await $`percy snapshot snapshots.yml`
+  const buildId = await runPercySnapshot();
+  try {
+    await $`percy build:wait --fail-on-changes --build ${buildId}`;
+  } catch (e) {
+    console.error('@noomorph says: This is a known issue. I contacted already their support team.');
+  }
 } finally {
   await server.stop();
 }


Test patch:
diff --git a/detox/test/android/build.gradle b/detox/test/android/build.gradle
index eda49f448..81a1cc43d 100644
--- a/detox/test/android/build.gradle
+++ b/detox/test/android/build.gradle
@@ -2,7 +2,8 @@ buildscript {
     apply from: './rninfo.gradle'
 
     def androidGradlePluginVersion =
-            rnInfo.isRN69OrHigher ? '7.1.1'
+            rnInfo.isRN70OrHigher ? '7.2.1'
+            : rnInfo.isRN69OrHigher ? '7.1.1'
             : rnInfo.isRN68OrHigher ? '7.0.4'
             : rnInfo.isRN66OrHigher ? '4.2.2'
             : '4.1.0'
diff --git a/detox/test/android/gradle/wrapper/gradle-wrapper.properties b/detox/test/android/gradle/wrapper/gradle-wrapper.properties
index f8e24aa8b..37d820d8a 100644
--- a/detox/test/android/gradle/wrapper/gradle-wrapper.properties
+++ b/detox/test/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Thu May 27 11:24:29 IDT 2021
+#Thu Feb 09 21:36:01 IST 2023
 distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
 distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
+zipStoreBase=GRADLE_USER_HOME
diff --git a/detox/test/android/rninfo.gradle b/detox/test/android/rninfo.gradle
index 384e3ffce..2813e15e6 100644
--- a/detox/test/android/rninfo.gradle
+++ b/detox/test/android/rninfo.gradle
@@ -9,6 +9,7 @@ project.ext.rnInfo = [
     isRN66OrHigher: rnMajorVer >= 66,
     isRN68OrHigher: rnMajorVer >= 68,
     isRN69OrHigher: rnMajorVer >= 69,
+    isRN70OrHigher: rnMajorVer >= 70,
 ]
 
 private static def getRNMajorVersion() {
diff --git a/detox/test/ios/Podfile b/detox/test/ios/Podfile
index 17921899b..a593d3a08 100644
--- a/detox/test/ios/Podfile
+++ b/detox/test/ios/Podfile
@@ -4,10 +4,12 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
 platform :ios, '12.4'
 install! 'cocoapods', :deterministic_uuids => false
 
+production = ENV["PRODUCTION"] == "1"
+
 def shared_pods
   config = use_native_modules!
 
-    if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.6[8,9].*/)
+    if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.(68|69|70).*/)
       # Flags change depending on the env values.
       flags = get_default_flags()
 
@@ -38,9 +40,19 @@ target 'example_ci' do
 end
 
 post_install do |installer|
-  react_native_post_install(installer)
+  if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.6[6,7,8,9].*/)
+    react_native_post_install(installer)
+  else
+    react_native_post_install(
+      installer,
+        # Set `mac_catalyst_enabled` to `true` in order to apply patches
+        # necessary for Mac Catalyst builds
+        :mac_catalyst_enabled => false
+    )    
+  end
+
   # See https://github.com/wix/Detox/pull/3035#discussion_r774747705
-  if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.6[6,7,8,9].*/)
+  if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.(66|67|68|69|70).*/)
     __apply_Xcode_12_5_M1_post_install_workaround(installer)
   end
 end
diff --git a/detox/test/package.json b/detox/test/package.json
index 081d93319..825ffc232 100644
--- a/detox/test/package.json
+++ b/detox/test/package.json
@@ -39,8 +39,8 @@
     "@react-native-picker/picker": "^2.1.0",
     "@react-native-segmented-control/segmented-control": "2.3.0",
     "moment": "^2.24.0",
-    "react": "18.0.0",
-    "react-native": "0.69.7",
+    "react": "18.1.0",
+    "react-native": "0.70.7",
     "react-native-gradle-plugin": "^0.0.7",
     "react-native-launch-arguments": "^3.1.0",
     "react-native-webview": "^11.18.1"
@@ -82,4 +82,4 @@
   "detox": {
     "extends": "./e2e/detox.config"
   }
-}
+}
\ No newline at end of file