detox 21.0.0-breaking.new-global-lifecycle.0 → 21.0.1-rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. package/.eslintrc.js +2 -7
  2. package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar → 21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar} +0 -0
  3. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.md5 +1 -0
  4. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha1 +1 -0
  5. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha256 +1 -0
  6. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha512 +1 -0
  7. package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar → 21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar} +0 -0
  8. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.md5 +1 -0
  9. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha1 +1 -0
  10. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha256 +1 -0
  11. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha512 +1 -0
  12. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar +0 -0
  13. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.md5 +1 -0
  14. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha1 +1 -0
  15. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha256 +1 -0
  16. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha512 +1 -0
  17. package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom → 21.0.1-rc.0/detox-21.0.1-rc.0.pom} +22 -10
  18. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.md5 +1 -0
  19. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha1 +1 -0
  20. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha256 +1 -0
  21. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha512 +1 -0
  22. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  26. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  27. package/Detox-ios-framework.tbz +0 -0
  28. package/Detox-ios-src.tbz +0 -0
  29. package/Detox-ios-xcuitest.tbz +0 -0
  30. package/README.md +1 -1
  31. package/android/build.gradle +13 -8
  32. package/android/detox/build.gradle +24 -13
  33. package/android/detox/proguard-rules-app.pro +6 -0
  34. package/android/detox/proguard-rules.pro +3 -0
  35. package/android/detox/publish-pom.gradle +5 -1
  36. package/android/detox/publishing.gradle +35 -33
  37. package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
  38. package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
  39. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +4 -4
  40. package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
  41. package/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +3 -1
  42. package/android/detox/src/full/java/com/wix/detox/common/UIExtensions.kt +28 -0
  43. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +37 -3
  44. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +11 -1
  45. package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +1 -1
  46. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +22 -0
  47. package/android/detox/src/{main → full}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +17 -4
  48. package/android/detox/src/full/java/com/wix/detox/espresso/action/RNDetoxAccessibilityAction.kt +46 -0
  49. package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +75 -0
  50. package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
  51. package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
  52. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +24 -28
  53. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/WithAccessibilityLabelMatcher.kt +23 -0
  54. package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
  55. package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
  56. package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResourceDescription.kt +26 -0
  57. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
  58. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
  59. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeLoadingMonitor.kt +54 -8
  60. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
  61. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +3 -4
  62. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
  63. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
  64. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +43 -34
  65. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
  66. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
  67. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +2 -6
  68. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/RN66Workaround.kt +13 -4
  69. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
  70. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
  71. package/android/detox/src/full/java/com/wix/detox/reactnative/ui/UIExtensions.kt +37 -0
  72. package/android/detox/src/full/java/com/wix/detox/reactnative/utils/RNUtils.kt +6 -0
  73. package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +4 -1
  74. package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
  75. package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +2 -1
  76. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +10 -0
  77. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt +1 -1
  78. package/android/detox/src/testFull/java/com/wix/detox/UTHelpers.kt +12 -0
  79. package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
  80. package/android/detox/src/testFull/java/com/wix/detox/common/UIExtensionsTest.kt +107 -0
  81. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
  82. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +22 -9
  83. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +39 -0
  84. package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/ViewAtIndexMatcherSpec.kt +1 -2
  85. package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
  86. package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
  87. package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
  88. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
  89. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
  90. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
  91. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
  92. package/android/gradle/wrapper/gradle-wrapper.properties +2 -1
  93. package/android/gradlew +181 -107
  94. package/index.d.ts +239 -83
  95. package/index.js +12 -1
  96. package/internals.d.ts +219 -45
  97. package/internals.js +10 -3
  98. package/local-cli/build-framework-cache.js +1 -1
  99. package/local-cli/build-xcuitest-cache.js +16 -0
  100. package/local-cli/build.js +2 -2
  101. package/local-cli/clean-framework-cache.js +1 -1
  102. package/local-cli/clean-xcuitest-cache.js +19 -0
  103. package/local-cli/cli.js +13 -7
  104. package/local-cli/init.js +61 -21
  105. package/local-cli/rebuild-framework-cache.js +4 -4
  106. package/local-cli/rebuild-xcuitest-cache.js +21 -0
  107. package/local-cli/reset-lock-file.js +16 -0
  108. package/local-cli/run-server.js +12 -1
  109. package/local-cli/start.js +49 -0
  110. package/local-cli/startCommand/AppStartCommand.js +65 -0
  111. package/local-cli/templates/jest.js +13 -10
  112. package/local-cli/test.js +14 -8
  113. package/local-cli/testCommand/TestRunnerCommand.js +126 -77
  114. package/local-cli/testCommand/TestRunnerError.js +13 -0
  115. package/local-cli/testCommand/builder.js +5 -1
  116. package/local-cli/testCommand/middlewares.js +4 -13
  117. package/local-cli/testCommand/warnings.js +0 -3
  118. package/local-cli/utils/cliErrorHandling.js +15 -0
  119. package/local-cli/utils/jestInternals.js +4 -1
  120. package/package.json +46 -26
  121. package/runners/deprecation.js +42 -44
  122. package/runners/jest/globalSetup.js +1 -1
  123. package/runners/jest/globalTeardown.js +1 -1
  124. package/runners/jest/index.d.ts +61 -0
  125. package/runners/jest/index.js +3 -8
  126. package/runners/jest/reporters/DetoxReporter.js +33 -2
  127. package/runners/jest/testEnvironment/index.js +119 -68
  128. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +97 -51
  129. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
  130. package/runners/jest/testEnvironment/listeners/SpecReporter.js +15 -17
  131. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +3 -7
  132. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  133. package/scripts/build_framework.ios.sh +26 -60
  134. package/scripts/build_local_framework.ios.sh +62 -0
  135. package/scripts/build_local_xcuitest.ios.sh +53 -0
  136. package/scripts/build_xcuitest.ios.sh +23 -0
  137. package/scripts/pack_ios.sh +14 -5
  138. package/scripts/postinstall.js +10 -4
  139. package/src/DetoxWorker.js +112 -64
  140. package/src/android/actions/native.js +16 -0
  141. package/src/android/core/NativeElement.js +72 -20
  142. package/src/android/core/NativeExpect.js +28 -9
  143. package/src/android/core/NativeMatcher.js +31 -10
  144. package/src/android/core/NativeWaitFor.js +8 -0
  145. package/src/android/espressoapi/DetoxAction.js +37 -0
  146. package/src/android/espressoapi/DetoxMatcher.js +24 -0
  147. package/src/android/espressoapi/EspressoDetox.js +1 -1
  148. package/src/android/espressoapi/web/WebElement.js +1 -1
  149. package/src/android/interactions/native.js +25 -18
  150. package/src/android/matchers/index.js +2 -2
  151. package/src/android/matchers/native.js +10 -3
  152. package/src/artifacts/ArtifactsManager.js +14 -47
  153. package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
  154. package/src/artifacts/log/android/ADBLogcatRecording.js +11 -28
  155. package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
  156. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
  157. package/src/artifacts/templates/artifact/Artifact.js +1 -1
  158. package/src/artifacts/templates/plugin/ArtifactPlugin.js +2 -2
  159. package/src/artifacts/templates/plugin/TwoSnapshotsPerTestPlugin.js +2 -1
  160. package/src/artifacts/templates/plugin/WholeTestRecorderPlugin.js +3 -2
  161. package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
  162. package/src/artifacts/utils/temporaryPath.js +47 -8
  163. package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
  164. package/src/client/AsyncWebSocket.js +11 -19
  165. package/src/client/Client.js +35 -3
  166. package/src/client/actions/SyncStatusSchema.json +21 -0
  167. package/src/client/actions/actions.js +38 -0
  168. package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
  169. package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
  170. package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
  171. package/src/configuration/collectCliConfig.js +3 -13
  172. package/src/configuration/composeAppsConfig.js +5 -1
  173. package/src/configuration/composeDeviceConfig.js +1 -1
  174. package/src/configuration/composeLoggerConfig.js +20 -10
  175. package/src/configuration/composeRunnerConfig.js +62 -9
  176. package/src/configuration/index.js +14 -9
  177. package/src/configuration/loadExternalConfig.js +1 -1
  178. package/src/devices/allocation/DeviceAllocator.js +15 -2
  179. package/src/devices/allocation/drivers/AllocationDriverBase.js +10 -2
  180. package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +10 -1
  181. package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
  182. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +28 -29
  183. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
  184. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +6 -5
  185. package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
  186. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +4 -17
  187. package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +27 -18
  188. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
  189. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +12 -7
  190. package/src/devices/allocation/factories/base.js +1 -1
  191. package/src/devices/common/drivers/android/exec/ADB.js +9 -0
  192. package/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.js +1 -1
  193. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
  194. package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  195. package/src/devices/common/drivers/android/tools/AppInstallHelper.js +4 -4
  196. package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
  197. package/src/devices/common/drivers/android/tools/{FileXfer.js → FileTransfer.js} +2 -2
  198. package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
  199. package/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js +1 -1
  200. package/src/devices/common/drivers/android/tools/TempFileTransfer.js +14 -0
  201. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +21 -4
  202. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
  203. package/src/devices/runtime/RuntimeDevice.js +24 -12
  204. package/src/devices/runtime/drivers/DeviceDriverBase.js +2 -1
  205. package/src/devices/runtime/drivers/android/AndroidDriver.js +17 -8
  206. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +42 -2
  207. package/src/devices/runtime/drivers/ios/XCUITestUtils.js +209 -0
  208. package/src/devices/runtime/drivers/ios/allowNetworkPermissionsXCUITest.scpt +14 -0
  209. package/src/devices/runtime/factories/android.js +6 -5
  210. package/src/devices/runtime/factories/base.js +3 -2
  211. package/src/errors/DetoxConfigErrorComposer.js +18 -3
  212. package/src/errors/DetoxError.js +5 -1
  213. package/src/ios/expectTwo.js +199 -78
  214. package/src/ipc/IPCClient.js +36 -27
  215. package/src/ipc/IPCServer.js +40 -21
  216. package/src/ipc/SessionState.js +60 -0
  217. package/src/logger/DetoxLogger.js +287 -154
  218. package/src/logger/index.js +5 -0
  219. package/src/logger/utils/BunyanLogger.js +105 -0
  220. package/src/logger/utils/CategoryThreadDispatcher.js +37 -0
  221. package/src/logger/utils/DetoxLogFinalizer.js +166 -0
  222. package/src/logger/utils/MessageStack.js +35 -0
  223. package/src/logger/utils/ThreadDispatcher.js +61 -0
  224. package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +23 -6
  225. package/src/logger/utils/getMainCategory.js +5 -0
  226. package/src/logger/utils/sanitizeBunyanContext.js +30 -0
  227. package/src/logger/utils/streams/BunyanTransformer.js +72 -0
  228. package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
  229. package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
  230. package/src/logger/utils/streams/JSONLStringer.js +55 -0
  231. package/src/logger/utils/streams/index.js +7 -0
  232. package/src/logger/utils/streams/transformers.js +39 -0
  233. package/src/logger/utils/tracerLegacy.js +37 -0
  234. package/src/realms/DetoxContext.js +83 -66
  235. package/src/realms/DetoxInternalsFacade.js +9 -13
  236. package/src/realms/DetoxPrimaryContext.js +117 -74
  237. package/src/realms/DetoxSecondaryContext.js +32 -35
  238. package/src/{symbols.js → realms/symbols.js} +16 -22
  239. package/src/server/DetoxConnection.js +18 -23
  240. package/src/server/DetoxServer.js +7 -10
  241. package/src/server/DetoxSession.js +9 -6
  242. package/src/server/DetoxSessionManager.js +2 -1
  243. package/src/server/handlers/AnonymousConnectionHandler.js +1 -0
  244. package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
  245. package/src/servicelocator/android/index.js +2 -2
  246. package/src/utils/ExclusiveLockfile.js +1 -0
  247. package/src/utils/Timer.js +59 -36
  248. package/src/utils/argparse.js +11 -27
  249. package/src/utils/childProcess/exec.js +4 -2
  250. package/src/utils/childProcess/spawn.js +1 -1
  251. package/src/utils/dateUtils.js +5 -0
  252. package/src/utils/environment.js +55 -16
  253. package/src/utils/errorUtils.js +24 -3
  254. package/src/utils/invocationTraceDescriptions.js +44 -0
  255. package/src/utils/isPromise.js +8 -1
  256. package/src/utils/logger.js +2 -2
  257. package/src/utils/pathUtils.js +11 -0
  258. package/src/utils/shellUtils.js +17 -0
  259. package/src/utils/traceInvocationCall.js +21 -0
  260. package/src/utils/traceMethods.js +15 -0
  261. package/src/validation/ios/IosSimulatorEnvValidator.js +7 -4
  262. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
  263. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
  264. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
  265. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
  266. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
  267. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
  268. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
  269. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
  270. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar +0 -0
  271. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.md5 +0 -1
  272. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
  273. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
  274. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
  275. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.md5 +0 -1
  276. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
  277. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
  278. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
  279. package/Detox-ios.tbz +0 -0
  280. package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
  281. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
  282. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +0 -20
  283. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
  284. package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -36
  285. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +0 -59
  286. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
  287. package/local-cli/build.test.js +0 -104
  288. package/local-cli/run-server.test.js +0 -23
  289. package/local-cli/test.test.js +0 -515
  290. package/runners/jest/deprecation.js +0 -25
  291. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
  292. package/scripts/build_universal_framework.sh +0 -14
  293. package/scripts/build_universal_framework_legacy.sh +0 -76
  294. package/scripts/build_universal_framework_modern.sh +0 -28
  295. package/src/configuration/utils/warnings.js +0 -12
  296. package/src/devices/common/drivers/android/tools/TempFileXfer.js +0 -16
  297. package/src/ipc/state.js +0 -76
  298. package/src/logger/DetoxTraceEventBuilder.js +0 -21
  299. package/src/logger/DetoxTracer.js +0 -133
  300. package/src/logger/TraceThreadDispatcher.js +0 -52
  301. package/src/realms/index.js +0 -10
  302. package/src/utils/ChromeTracingExporter.js +0 -53
  303. package/src/utils/streamUtils.js +0 -214
  304. package/src/utils/trace.js +0 -19
@@ -7,7 +7,7 @@ const DetoxRuntimeError = require('../../../../../errors/DetoxRuntimeError');
7
7
  const { joinArgs } = require('../../../../../utils/argparse');
8
8
  const childProcess = require('../../../../../utils/childProcess');
9
9
  const environment = require('../../../../../utils/environment');
10
- const log = require('../../../../../utils/logger').child({ __filename });
10
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
11
11
  const { quote } = require('../../../../../utils/shellQuote');
12
12
 
13
13
  class AppleSimUtils {
@@ -93,7 +93,7 @@ class AppleSimUtils {
93
93
  `(https://developer.apple.com/xcode/). In case you already have the latest Xcode version installed, ` +
94
94
  `try run the command: \`sudo xcode-select -s /Applications/Xcode.app\`. If you are running tests from CI, ` +
95
95
  `we recommend running them with "--headless" device configuration (see: ` +
96
- `https://wix.github.io/Detox/docs/next/api/configuration/#device-configurations).`
96
+ `https://wix.github.io/Detox/docs/cli/test/#options).`
97
97
  );
98
98
  }
99
99
 
@@ -140,6 +140,9 @@ class AppleSimUtils {
140
140
 
141
141
  async launch(udid, bundleId, launchArgs, languageAndLocale) {
142
142
  const frameworkPath = await environment.getFrameworkPath();
143
+
144
+ delete launchArgs.detoxServer;
145
+
143
146
  const result = await this._launchMagically(frameworkPath, udid, bundleId, launchArgs, languageAndLocale);
144
147
  await this._printLoggingHint(udid, bundleId);
145
148
 
@@ -156,7 +159,19 @@ class AppleSimUtils {
156
159
  );
157
160
  }
158
161
 
159
- async sendToHome(udid) {
162
+ async _isSpringBoardInaccessible(udid) {
163
+ const device = await this._findDeviceByUDID(udid);
164
+ const majorIOSVersion = parseInt(device.os.version.split('.')[0]);
165
+ return majorIOSVersion >= 16;
166
+ }
167
+
168
+ async _launchAndTerminateSettings(udid) {
169
+ const bundleId = 'com.apple.Preferences';
170
+ await this._execSimctl({ cmd: `launch ${udid} ${bundleId}`, retries: 10 });
171
+ await this._execSimctl({ cmd: `terminate ${udid} ${bundleId}`, retries: 10 });
172
+ }
173
+
174
+ async _launchSpringBoard(udid) {
160
175
  await this._execSimctl({ cmd: `launch ${udid} com.apple.springboard`, retries: 10 });
161
176
  }
162
177
 
@@ -271,7 +286,9 @@ class AppleSimUtils {
271
286
  // ```
272
287
  // This workaround is done to ignore the error above, as we do not care if the app was running before, we just
273
288
  // want to make sure it isn't now.
274
- if (err.code === 3 && err.stderr.includes(`the app is not currently running`)) {
289
+ if (err.code === 3 &&
290
+ (err.stderr.includes(`the app is not currently running`) ||
291
+ err.stderr.includes(`The operation couldn’t be completed. found nothing to terminate`))) {
275
292
  return;
276
293
  }
277
294
 
@@ -1,6 +1,4 @@
1
- const onSignalExit = require('signal-exit');
2
-
3
- const logger = require('../../utils/logger').child({ __filename });
1
+ const logger = require('../../utils/logger').child({ cat: 'device' });
4
2
 
5
3
  const cleanupLogData = {
6
4
  event: 'GENYCLOUD_TEARDOWN',
@@ -8,20 +6,20 @@ const cleanupLogData = {
8
6
 
9
7
  class GenyGlobalLifecycleHandler {
10
8
  constructor({ deviceCleanupRegistry, instanceLifecycleService }) {
9
+ /** @private */
11
10
  this._deviceCleanupRegistry = deviceCleanupRegistry;
11
+ /** @private */
12
12
  this._instanceLifecycleService = instanceLifecycleService;
13
13
  }
14
14
 
15
- async globalInit() {
16
- onSignalExit((code, signal) => {
17
- if (signal) {
18
- const { rawDevices } = this._deviceCleanupRegistry.readRegisteredDevicesUNSAFE();
19
- const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
20
- if (instanceHandles.length) {
21
- reportGlobalCleanupSummary(instanceHandles);
22
- }
23
- }
24
- });
15
+ async globalInit() {}
16
+
17
+ emergencyCleanup() {
18
+ const { rawDevices } = this._deviceCleanupRegistry.readRegisteredDevicesUNSAFE();
19
+ const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
20
+ if (instanceHandles.length) {
21
+ reportGlobalCleanupSummary(instanceHandles);
22
+ }
25
23
  }
26
24
 
27
25
  async globalCleanup() {
@@ -34,7 +32,7 @@ class GenyGlobalLifecycleHandler {
34
32
  }
35
33
 
36
34
  async function doSafeCleanup(instanceLifecycleService, instanceHandles) {
37
- logger.info(cleanupLogData, 'Initiating Genymotion cloud instances teardown...');
35
+ logger.info(cleanupLogData, 'Initiating Genymotion SaaS instances teardown...');
38
36
 
39
37
  const deletionLeaks = [];
40
38
  const killPromises = instanceHandles.map((instanceHandle) =>
@@ -47,7 +45,7 @@ async function doSafeCleanup(instanceLifecycleService, instanceHandles) {
47
45
 
48
46
  function reportGlobalCleanupSummary(deletionLeaks) {
49
47
  if (deletionLeaks.length) {
50
- logger.warn(cleanupLogData, 'WARNING! Detected a Genymotion cloud instance leakage, for the following instances:');
48
+ logger.warn(cleanupLogData, 'WARNING! Detected a Genymotion SaaS instance leakage, for the following instances:');
51
49
 
52
50
  deletionLeaks.forEach(({ uuid, name, error }) => {
53
51
  logger.warn(cleanupLogData, [
@@ -1,6 +1,7 @@
1
1
  const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
2
2
  const debug = require('../../utils/debug'); // debug utils, leave here even if unused
3
- const { traceCall, traceMethods } = require('../../utils/trace');
3
+ const log = require('../../utils/logger').child({ cat: 'device' });
4
+ const traceMethods = require('../../utils/traceMethods');
4
5
  const wrapWithStackTraceCutter = require('../../utils/wrapWithStackTraceCutter');
5
6
 
6
7
  const LaunchArgsEditor = require('./utils/LaunchArgsEditor');
@@ -20,6 +21,7 @@ class RuntimeDevice {
20
21
  'disableSynchronization',
21
22
  'enableSynchronization',
22
23
  'installApp',
24
+ 'installUtilBinaries',
23
25
  'launchApp',
24
26
  'matchFace',
25
27
  'matchFinger',
@@ -48,9 +50,10 @@ class RuntimeDevice {
48
50
  'unreverseTcpPort',
49
51
  ];
50
52
 
51
- traceMethods(this, 'device', methodNames);
53
+ traceMethods(log, this, methodNames);
52
54
  wrapWithStackTraceCutter(this, methodNames);
53
55
 
56
+ this._isTestRunnerConnected = false;
54
57
  this._appsConfig = appsConfig;
55
58
  this._behaviorConfig = behaviorConfig;
56
59
  this._deviceConfig = deviceConfig;
@@ -155,8 +158,11 @@ class RuntimeDevice {
155
158
  this._processes[bundleId] = await this.deviceDriver.waitForAppLaunch(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
156
159
  } else {
157
160
  this._processes[bundleId] = await this.deviceDriver.launchApp(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
161
+ console.log('Launched app process:', this._processes[bundleId]);
158
162
  await this.deviceDriver.waitUntilReady();
163
+ console.log('wait for active');
159
164
  await this.deviceDriver.waitForActive();
165
+ console.log('App launched. Running test...');
160
166
  }
161
167
 
162
168
  await this._emitter.emit('appReady', {
@@ -234,29 +240,34 @@ class RuntimeDevice {
234
240
  }
235
241
 
236
242
  async installApp(binaryPath, testBinaryPath) {
237
- await traceCall('appInstall', () => {
238
- const currentApp = binaryPath ? { binaryPath, testBinaryPath } : this._getCurrentApp();
239
- return this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath);
240
- });
243
+ const currentApp = binaryPath ? { binaryPath, testBinaryPath } : this._getCurrentApp();
244
+ await this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath);
245
+
246
+ // This abstraction leaks because our drivers themselves leak,
247
+ // so don't blame me - DeviceBaseDriver itself has `reverseTcpPort`,
248
+ // setting a vicious downward spiral. I can't refactor everything
249
+ // in a single pull request, so let's bear with it for now.
250
+ if (Array.isArray(currentApp.reversePorts)) {
251
+ for (const port of currentApp.reversePorts) {
252
+ await this.reverseTcpPort(port);
253
+ }
254
+ }
241
255
  }
242
256
 
243
257
  async uninstallApp(bundleId) {
244
258
  const _bundleId = bundleId || this._bundleId;
245
- await traceCall('appUninstall', () =>
246
- this.deviceDriver.uninstallApp(_bundleId));
259
+ await this.deviceDriver.uninstallApp(_bundleId);
247
260
  }
248
261
 
249
262
  async installUtilBinaries() {
250
263
  const paths = this._deviceConfig.utilBinaryPaths;
251
264
  if (paths) {
252
- await traceCall('installUtilBinaries', () =>
253
- this.deviceDriver.installUtilBinaries(paths));
265
+ await this.deviceDriver.installUtilBinaries(paths);
254
266
  }
255
267
  }
256
268
 
257
269
  async reloadReactNative() {
258
- await traceCall('reloadRN', () =>
259
- this.deviceDriver.reloadReactNative());
270
+ await this.deviceDriver.reloadReactNative();
260
271
  }
261
272
 
262
273
  async openURL(params) {
@@ -355,6 +366,7 @@ class RuntimeDevice {
355
366
  }
356
367
  return this._currentApp;
357
368
  }
369
+
358
370
  async _sendPayload(key, params) {
359
371
  const payloadFilePath = this.deviceDriver.createPayloadFile(params);
360
372
  const payload = {
@@ -4,7 +4,7 @@ const path = require('path');
4
4
 
5
5
  const fs = require('fs-extra');
6
6
 
7
- const log = require('../../../utils/logger').child({ __filename });
7
+ const log = require('../../../utils/logger').child({ cat: 'device' });
8
8
 
9
9
  /**
10
10
  * @typedef DeviceDriverDeps
@@ -112,6 +112,7 @@ class DeviceDriverBase {
112
112
  }
113
113
 
114
114
  async waitUntilReady() {
115
+ console.warn('DeviceDriverBase.waitUntilReady()');
115
116
  return await this.client.waitUntilReady();
116
117
  }
117
118
 
@@ -1,3 +1,4 @@
1
+ /* eslint @typescript-eslint/no-unused-vars: ["error", { "args": "none" }] */
1
2
  // @ts-nocheck
2
3
  const path = require('path');
3
4
  const URL = require('url').URL;
@@ -18,7 +19,7 @@ const sleep = require('../../../../utils/sleep');
18
19
  const apkUtils = require('../../../common/drivers/android/tools/apk');
19
20
  const DeviceDriverBase = require('../DeviceDriverBase');
20
21
 
21
- const log = logger.child({ __filename });
22
+ const log = logger.child({ cat: 'device' });
22
23
 
23
24
  /**
24
25
  * @typedef AndroidDriverProps
@@ -31,7 +32,7 @@ const log = logger.child({ __filename });
31
32
  * @property adb { ADB }
32
33
  * @property aapt { AAPT }
33
34
  * @property apkValidator { ApkValidator }
34
- * @property fileXfer { FileXfer }
35
+ * @property fileTransfer { FileTransfer }
35
36
  * @property appInstallHelper { AppInstallHelper }
36
37
  * @property appUninstallHelper { AppUninstallHelper }
37
38
  * @property devicePathBuilder { AndroidDevicePathBuilder }
@@ -51,7 +52,7 @@ class AndroidDriver extends DeviceDriverBase {
51
52
  this.aapt = deps.aapt;
52
53
  this.apkValidator = deps.apkValidator;
53
54
  this.invocationManager = deps.invocationManager;
54
- this.fileXfer = deps.fileXfer;
55
+ this.fileTransfer = deps.fileTransfer;
55
56
  this.appInstallHelper = deps.appInstallHelper;
56
57
  this.appUninstallHelper = deps.appUninstallHelper;
57
58
  this.devicePathBuilder = deps.devicePathBuilder;
@@ -148,17 +149,25 @@ class AndroidDriver extends DeviceDriverBase {
148
149
 
149
150
  async waitUntilReady() {
150
151
  try {
151
- await Promise.race([super.waitUntilReady(), this.instrumentation.waitForCrash()]);
152
+ await Promise.race([
153
+ super.waitUntilReady(),
154
+ this.instrumentation.waitForCrash()
155
+ ]);
156
+ } catch (e) {
157
+ log.warn({ error: e }, 'An error occurred while waiting for the app to become ready. Waiting for disconnection...');
158
+ await this.client.waitUntilDisconnected();
159
+ log.warn('The app disconnected.');
160
+ throw e;
152
161
  } finally {
153
162
  this.instrumentation.abortWaitForCrash();
154
163
  }
155
164
  }
156
165
 
157
- async pressBack() { // eslint-disable-line no-unused-vars
166
+ async pressBack() {
158
167
  await this.uiDevice.pressBack();
159
168
  }
160
169
 
161
- async sendToHome(params) { // eslint-disable-line no-unused-vars
170
+ async sendToHome(params) {
162
171
  await this.uiDevice.pressHome();
163
172
  }
164
173
 
@@ -323,8 +332,8 @@ class AndroidDriver extends DeviceDriverBase {
323
332
  }
324
333
 
325
334
  async _sendNotificationDataToDevice(dataFileLocalPath, adbName) {
326
- await this.fileXfer.prepareDestinationDir(adbName);
327
- return await this.fileXfer.send(adbName, dataFileLocalPath, 'notification.json');
335
+ await this.fileTransfer.prepareDestinationDir(adbName);
336
+ return await this.fileTransfer.send(adbName, dataFileLocalPath, 'notification.json');
328
337
  }
329
338
 
330
339
  _startActivityWithUrl(url) {
@@ -6,11 +6,14 @@ const _ = require('lodash');
6
6
 
7
7
  const temporaryPath = require('../../../../artifacts/utils/temporaryPath');
8
8
  const DetoxRuntimeError = require('../../../../errors/DetoxRuntimeError');
9
+ const environment = require('../../../../utils/environment');
9
10
  const getAbsoluteBinaryPath = require('../../../../utils/getAbsoluteBinaryPath');
10
- const log = require('../../../../utils/logger').child({ __filename });
11
+ const log = require('../../../../utils/logger').child({ cat: 'driver' });
11
12
  const pressAnyKey = require('../../../../utils/pressAnyKey');
12
13
 
13
14
  const IosDriver = require('./IosDriver');
15
+ const { launchXCUITest } = require('./XCUITestUtils');
16
+
14
17
 
15
18
  /**
16
19
  * @typedef SimulatorDriverDeps { DeviceDriverDeps }
@@ -40,6 +43,8 @@ class SimulatorDriver extends IosDriver {
40
43
  this._deviceName = `${udid} (${this._type})`;
41
44
  this._simulatorLauncher = deps.simulatorLauncher;
42
45
  this._applesimutils = deps.applesimutils;
46
+ // TODO: allocate unique-per-worker available port.
47
+ this._testTargetServerPort = 8997 + _.random(0, 1000);
43
48
  }
44
49
 
45
50
  getExternalId() {
@@ -75,19 +80,48 @@ class SimulatorDriver extends IosDriver {
75
80
  }
76
81
 
77
82
  async launchApp(bundleId, launchArgs, languageAndLocale) {
83
+ const xcuitestRunnerPath = await environment.getXCUITestRunnerPath();
84
+
78
85
  const { udid } = this;
86
+ launchArgs = this.enrichArgs(launchArgs);
87
+
79
88
  await this.emitter.emit('beforeLaunchApp', { bundleId, deviceId: udid, launchArgs });
89
+
90
+ log.debug({ event: 'CLIENT_CONNECTED', params: { connected: this.client.isConnected } }, 'client connected: ' + this.client.isConnected);
91
+ if (!this.client.isConnected) {
92
+ await launchXCUITest(
93
+ xcuitestRunnerPath,
94
+ this.udid,
95
+ launchArgs.detoxServer,
96
+ launchArgs.detoxSessionId,
97
+ bundleId,
98
+ launchArgs.detoxDebugVisibility,
99
+ launchArgs.detoxDisableHierarchyDump,
100
+ this._testTargetServerPort
101
+ );
102
+ }
103
+
80
104
  const pid = await this._applesimutils.launch(udid, bundleId, launchArgs, languageAndLocale);
81
105
  await this.emitter.emit('launchApp', { bundleId, deviceId: udid, launchArgs, pid });
82
106
 
83
107
  return pid;
84
108
  }
85
109
 
110
+ enrichArgs(args) {
111
+ return {
112
+ ...args,
113
+ detoxTestTargetServer: 'ws://localhost:' + this._testTargetServerPort,
114
+ };
115
+ }
116
+
86
117
  async waitForAppLaunch(bundleId, launchArgs, languageAndLocale) {
87
118
  const { udid } = this;
88
119
 
120
+ launchArgs = this.enrichArgs(launchArgs);
121
+
89
122
  await this.emitter.emit('beforeLaunchApp', { bundleId, deviceId: udid, launchArgs });
90
123
 
124
+ // print xcuitest launch hint
91
125
  this._applesimutils.printLaunchHint(udid, bundleId, launchArgs, languageAndLocale);
92
126
  await pressAnyKey();
93
127
 
@@ -109,6 +143,12 @@ class SimulatorDriver extends IosDriver {
109
143
  async terminate(bundleId) {
110
144
  const { udid } = this;
111
145
  await this.emitter.emit('beforeTerminateApp', { deviceId: udid, bundleId });
146
+
147
+ await this.client.terminateIfNeeded();
148
+
149
+ // Sleep for 200 ms to allow the XCUITest to terminate gracefully.
150
+ await new Promise(resolve => setTimeout(resolve, 200));
151
+
112
152
  await this._applesimutils.terminate(udid, bundleId);
113
153
  await this.emitter.emit('terminateApp', { deviceId: udid, bundleId });
114
154
  }
@@ -134,7 +174,7 @@ class SimulatorDriver extends IosDriver {
134
174
  }
135
175
 
136
176
  async sendToHome() {
137
- await this._applesimutils.sendToHome(this.udid);
177
+ return await this.client.sendToHome();
138
178
  }
139
179
 
140
180
  async setLocation(lat, lon) {
@@ -0,0 +1,209 @@
1
+ const { exec } = require('child-process-promise');
2
+ const osascript = require('node-osascript');
3
+
4
+ const { execWithRetriesAndLogs } = require('../../../../utils/childProcess');
5
+ const log = require('../../../../utils/logger').child({ cat: 'device,xcuitest' });
6
+
7
+ async function launchXCUITest(
8
+ xcuitestRunnerPath,
9
+ simulatorId,
10
+ detoxServer,
11
+ detoxSessionId,
12
+ bundleId,
13
+ debugVisibility,
14
+ disableDumpViewHierarchy,
15
+ testTargetServerPort
16
+ ) {
17
+ log.debug('[XCUITest] Launch was called');
18
+
19
+ await _runLaunchCommand(
20
+ xcuitestRunnerPath,
21
+ simulatorId,
22
+ detoxServer,
23
+ detoxSessionId,
24
+ bundleId,
25
+ debugVisibility,
26
+ disableDumpViewHierarchy,
27
+ testTargetServerPort
28
+ );
29
+
30
+ log.debug('[XCUITest] Launch succeeded');
31
+ }
32
+
33
+ async function _runLaunchCommand(
34
+ xcuitestRunnerPath,
35
+ simulatorId,
36
+ detoxServer,
37
+ detoxSessionId,
38
+ bundleId,
39
+ debugVisibility,
40
+ disableDumpViewHierarchy,
41
+ testTargetServerPort
42
+ ) {
43
+ log.info(`Launching XUICTest runner. See target logs using:\n` +
44
+ `\t/usr/bin/xcrun simctl spawn ${simulatorId} log stream --level debug --style compact ` +
45
+ `--predicate 'process == "DetoxTester-Runner" && subsystem == "com.wix.DetoxTester.xctrunner"'`);
46
+
47
+ const spawnedProcess = runXCUITest(
48
+ xcuitestRunnerPath,
49
+ simulatorId,
50
+ detoxServer,
51
+ detoxSessionId,
52
+ testTargetServerPort,
53
+ bundleId,
54
+ debugVisibility,
55
+ disableDumpViewHierarchy
56
+ ).then(r => {
57
+ log.info(`[XCUITest] XCUITest runner execution finished`);
58
+ }).catch(e => {
59
+ log.error(`[XCUITest] xcodebuild error has occurred during XCUITest execution:\n${e}`);
60
+ });
61
+
62
+ // Get firewall global state (Firewall socketfilterfw):
63
+ const state = await exec(`/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate`);
64
+ const isFirewallDisabled = state.stdout.toString().includes('Firewall is disabled');
65
+ if (!isFirewallDisabled) {
66
+ _allowNetworkPermissionsXCUITest();
67
+ }
68
+
69
+ const isServerUp = await _waitForTestTargetServerToStart(testTargetServerPort, spawnedProcess);
70
+ log.debug(`[XCUITest] Finished waiting for test target server to start, server is up: ${isServerUp}`);
71
+ }
72
+
73
+ function runXCUITest(
74
+ xcuitestRunnerPath,
75
+ simulatorId,
76
+ detoxServer,
77
+ detoxSessionId,
78
+ testTargetServerPort,
79
+ bundleId,
80
+ debugVisibility,
81
+ disableDumpViewHierarchy,
82
+ ) {
83
+ log.debug(`[XCUITest] Running xcodebuild test with bundle id: ${bundleId}`);
84
+ let xcodebuildBinary = 'xcodebuild';
85
+ const flags = [
86
+ '-xctestrun', xcuitestRunnerPath,
87
+ '-sdk', 'iphonesimulator',
88
+ '-allowProvisioningUpdates',
89
+ '-destination', `platform=iOS Simulator,id=${simulatorId}`,
90
+ 'test-without-building'
91
+ ];
92
+
93
+ const env = {
94
+ TEST_RUNNER_IS_DETOX_ACTIVE: '1',
95
+ TEST_RUNNER_DETOX_SERVER: detoxServer,
96
+ TEST_RUNNER_DETOX_SESSION_ID: detoxSessionId,
97
+ TEST_RUNNER_TEST_TARGET_SERVER_PORT: testTargetServerPort,
98
+ TEST_RUNNER_BUNDLE_ID: bundleId,
99
+ TEST_RUNNER_DETOX_DEBUG_VISIBILITY: debugVisibility,
100
+ TEST_RUNNER_DETOX_DISABLE_VIEW_HIERARCHY_DUMP: disableDumpViewHierarchy
101
+ };
102
+
103
+ const options = {
104
+ maxBuffer: 1024 * 1024 * 1024,
105
+ retries: 1,
106
+ verbosity: 'high',
107
+ };
108
+
109
+ const command = `${env.TEST_RUNNER_IS_DETOX_ACTIVE ? Object.keys(env).map(key => `${key}=${env[key]}`).join(' ') : ''} ${xcodebuildBinary} ${flags.map(flag => flag.includes(' ') ? `"${flag}"` : flag).join(' ')}`;
110
+ log.debug(`[XCUITest] Running command: ${command}`);
111
+
112
+ // TODO: consider using this instead of the Terminal approach below.
113
+ // const isRunningOnTerminal = process.stdout.isTTY;
114
+ // if (isRunningOnTerminal === true) {
115
+ // return execWithRetriesAndLogs(command, options);
116
+ // }
117
+ //
118
+ // log.info(`[XCUITest] Currently not running through the Terminal, will run the xcodebuild command on the Terminal`);
119
+ return _runCommandInTerminal(command, options);
120
+ }
121
+
122
+ function _runCommandInTerminal(command, options) {
123
+ const escapedCommand = command.replace(/"/g, '\\"'); // escape double quotes
124
+
125
+ // opens the Terminal app and runs the command in a new window, then closes the window when the command is done running.
126
+ const appleScript = `
127
+ tell application "Terminal"
128
+ if not running then
129
+ open
130
+ end if
131
+
132
+ activate
133
+ do script "${escapedCommand}; exit"
134
+
135
+ repeat
136
+ delay 1
137
+ if not busy of window 1 then
138
+ close window 1
139
+ exit repeat
140
+ end if
141
+ end repeat
142
+ end tell
143
+ `;
144
+
145
+ return execWithRetriesAndLogs(`osascript -e '${appleScript}'`, options);
146
+ }
147
+
148
+ function _allowNetworkPermissionsXCUITest() {
149
+ log.debug(`[XCUITest] Allowing network permissions`);
150
+ let didCallback = false;
151
+
152
+ const childProcess = osascript.executeFile(
153
+ `${__dirname}/allowNetworkPermissionsXCUITest.scpt`,
154
+ function(err, _, __) {
155
+ if (err) {
156
+ log.error(`[XCUITest] Failed to approve network permissions for XCUITest target:\n\t${err}`);
157
+ } else {
158
+ log.debug(`[XCUITest] Network permissions are allowed`);
159
+ }
160
+
161
+ didCallback = true;
162
+ });
163
+
164
+ setTimeout(() => {
165
+ if (didCallback || !childProcess) {
166
+ return;
167
+ }
168
+
169
+ log.debug(`[XCUITest] Killing the process that allows network permissions (timed-out)`);
170
+ childProcess.stdin.pause();
171
+ childProcess.kill('SIGTERM');
172
+
173
+ }, 30000);
174
+ }
175
+
176
+ async function _waitForTestTargetServerToStart(testTargetServerPort, cpPromise) {
177
+ log.debug(`[XCUITest] Waiting for test target server to start on port ${testTargetServerPort}...`);
178
+ let isServerUp = false;
179
+ let retries = 0;
180
+
181
+ while (!isServerUp && retries++ < 90) {
182
+ try {
183
+ await exec(`nc -z localhost ${testTargetServerPort}`);
184
+ isServerUp = true;
185
+ } catch (e) {
186
+ log.debug(`[XCUITest] Test target server is not up yet, waiting...`);
187
+ await new Promise(resolve => setTimeout(resolve, 1000));
188
+ }
189
+ }
190
+
191
+ if (!isServerUp) {
192
+ log.error(`[XCUITest] Test target server is not up after 90 seconds, aborting`);
193
+
194
+ if (cpPromise && cpPromise.childProcess && cpPromise.childProcess.kill('SIGTERM')) {
195
+ log.debug(`[XCUITest] Test target process was killed`);
196
+ } else {
197
+ log.debug(`[XCUITest] Test target process was not killed`);
198
+ }
199
+
200
+ return false;
201
+ }
202
+
203
+ log.debug(`[XCUITest] Test target server is up and running`);
204
+ return true;
205
+ }
206
+
207
+ module.exports = {
208
+ launchXCUITest
209
+ };
@@ -0,0 +1,14 @@
1
+ tell application "System Events"
2
+ set frontmost of process "UserNotificationCenter" to true
3
+ tell process "UserNotificationCenter"
4
+ repeat until (exists button "Allow" of window 1)
5
+ delay 1
6
+ end repeat
7
+
8
+ repeat while exists button "Allow" of window 1
9
+ if exists button "Allow" of window 1 then
10
+ click button "Allow" of window 1
11
+ end if
12
+ end repeat
13
+ end tell
14
+ end tell
@@ -1,3 +1,4 @@
1
+ /* eslint @typescript-eslint/no-unused-vars: ["error", { "args": "none" }] */
1
2
  const RuntimeDeviceFactory = require('./base');
2
3
 
3
4
  class RuntimeDriverFactoryAndroid extends RuntimeDeviceFactory {
@@ -6,7 +7,7 @@ class RuntimeDriverFactoryAndroid extends RuntimeDeviceFactory {
6
7
  const adb = serviceLocator.adb;
7
8
  const aapt = serviceLocator.aapt;
8
9
  const apkValidator = serviceLocator.apkValidator;
9
- const fileXfer = serviceLocator.fileXfer;
10
+ const fileTransfer = serviceLocator.fileTransfer;
10
11
  const devicePathBuilder = serviceLocator.devicePathBuilder;
11
12
 
12
13
  const AppInstallHelper = require('../../common/drivers/android/tools/AppInstallHelper');
@@ -18,9 +19,9 @@ class RuntimeDriverFactoryAndroid extends RuntimeDeviceFactory {
18
19
  adb,
19
20
  aapt,
20
21
  apkValidator,
21
- fileXfer,
22
+ fileTransfer,
22
23
  devicePathBuilder,
23
- appInstallHelper: new AppInstallHelper(adb, fileXfer),
24
+ appInstallHelper: new AppInstallHelper(adb, fileTransfer),
24
25
  appUninstallHelper: new AppUninstallHelper(adb),
25
26
  instrumentation: new MonitoredInstrumentation(adb),
26
27
  };
@@ -41,7 +42,7 @@ class AndroidEmulator extends RuntimeDriverFactoryAndroid {
41
42
  }
42
43
 
43
44
  class AndroidAttached extends RuntimeDriverFactoryAndroid {
44
- _createDriver(deviceCookie, deps, configs) { // eslint-disable-line no-unused-vars
45
+ _createDriver(deviceCookie, deps, configs) {
45
46
  const props = {
46
47
  adbName: deviceCookie.adbName,
47
48
  };
@@ -52,7 +53,7 @@ class AndroidAttached extends RuntimeDriverFactoryAndroid {
52
53
  }
53
54
 
54
55
  class Genycloud extends RuntimeDriverFactoryAndroid {
55
- _createDriver(deviceCookie, deps, configs) { // eslint-disable-line no-unused-vars
56
+ _createDriver(deviceCookie, deps, configs) {
56
57
  const props = {
57
58
  instance: deviceCookie.instance,
58
59
  };
@@ -1,3 +1,4 @@
1
+ /* eslint @typescript-eslint/no-unused-vars: ["error", { "args": "none" }] */
1
2
  const RuntimeDevice = require('../RuntimeDevice');
2
3
 
3
4
  class RuntimeDeviceFactory {
@@ -7,8 +8,8 @@ class RuntimeDeviceFactory {
7
8
  return new RuntimeDevice({ ...commonDeps, ...configs }, runtimeDriver);
8
9
  }
9
10
 
10
- _createDriverDependencies(commonDeps) { } // eslint-disable-line no-unused-vars
11
- _createDriver(deviceCookie, deps, configs) {} // eslint-disable-line no-unused-vars
11
+ _createDriverDependencies(commonDeps) { }
12
+ _createDriver(deviceCookie, deps, configs) {}
12
13
  }
13
14
 
14
15
  module.exports = RuntimeDeviceFactory;