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
@@ -105,18 +105,23 @@ async function composeDetoxConfig({
105
105
  });
106
106
 
107
107
  const result = {
108
- appsConfig,
109
- artifactsConfig,
110
- behaviorConfig,
111
- cliConfig,
112
108
  configurationName,
113
- deviceConfig,
114
- errorComposer,
115
- loggerConfig,
116
- runnerConfig,
117
- sessionConfig,
109
+
110
+ apps: appsConfig,
111
+ artifacts: artifactsConfig,
112
+ behavior: behaviorConfig,
113
+ cli: cliConfig,
114
+ device: deviceConfig,
115
+ logger: loggerConfig,
116
+ testRunner: runnerConfig,
117
+ session: sessionConfig,
118
118
  };
119
119
 
120
+ Object.defineProperty(result, 'errorComposer', {
121
+ enumerable: false,
122
+ value: errorComposer,
123
+ });
124
+
120
125
  return result;
121
126
  }
122
127
 
@@ -6,7 +6,7 @@ const fs = require('fs-extra');
6
6
  const _ = require('lodash');
7
7
  const resolveFrom = require('resolve-from');
8
8
 
9
- const log = require('../utils/logger').child({ __filename });
9
+ const log = require('../utils/logger').child({ cat: 'config' });
10
10
 
11
11
  async function locateExternalConfig(cwd) {
12
12
  return findUp([
@@ -1,5 +1,6 @@
1
1
  // @ts-nocheck
2
- const { traceMethods } = require('../../utils/trace');
2
+ const log = require('../../utils/logger').child({ cat: 'device' });
3
+ const traceMethods = require('../../utils/traceMethods');
3
4
 
4
5
  class DeviceAllocator {
5
6
  /**
@@ -7,7 +8,7 @@ class DeviceAllocator {
7
8
  */
8
9
  constructor(allocationDriver) {
9
10
  this._driver = allocationDriver;
10
- traceMethods(this, 'device', ['allocate', 'free']);
11
+ traceMethods(log, this, ['allocate', 'postAllocate', 'free']);
11
12
  }
12
13
 
13
14
  /**
@@ -18,6 +19,18 @@ class DeviceAllocator {
18
19
  return this._driver.allocate(deviceConfig);
19
20
  }
20
21
 
22
+ /**
23
+ * @param {DeviceCookie} deviceCookie
24
+ * @return {Promise<unknown>}
25
+ */
26
+ postAllocate(deviceCookie) {
27
+ if (typeof this._driver.postAllocate !== 'function') {
28
+ return Promise.resolve();
29
+ }
30
+
31
+ return this._driver.postAllocate(deviceCookie);
32
+ }
33
+
21
34
  /**
22
35
  * @param cookie { DeviceCookie }
23
36
  * @param options { DeallocOptions }
@@ -1,4 +1,6 @@
1
+ /* eslint @typescript-eslint/no-unused-vars: ["error", { "args": "none" }] */
1
2
  // @ts-nocheck
3
+
2
4
  /**
3
5
  * @typedef DeallocOptions
4
6
  * @property shutdown { Boolean }
@@ -9,14 +11,20 @@ class AllocationDriverBase {
9
11
  * @param deviceConfig { Object }
10
12
  * @return {Promise<DeviceCookie>}
11
13
  */
12
- async allocate(deviceConfig) {} // eslint-disable-line no-unused-vars
14
+ async allocate(deviceConfig) {}
15
+
16
+ /**
17
+ * @param {DeviceCookie} deviceCookie
18
+ * @return {Promise<void>}
19
+ */
20
+ async postAllocate(deviceCookie) {}
13
21
 
14
22
  /**
15
23
  * @param cookie { DeviceCookie }
16
24
  * @param options { DeallocOptions }
17
25
  * @return {Promise<void>}
18
26
  */
19
- async free(cookie, options) {} // eslint-disable-line no-unused-vars
27
+ async free(cookie, options) {}
20
28
  }
21
29
 
22
30
  module.exports = AllocationDriverBase;
@@ -25,11 +25,20 @@ class AttachedAndroidAllocDriver extends AllocationDriverBase {
25
25
  const adbNamePattern = deviceConfig.device.adbName;
26
26
  const adbName = await this._deviceRegistry.allocateDevice(() => this._freeDeviceFinder.findFreeDevice(adbNamePattern));
27
27
 
28
+ return new AttachedAndroidDeviceCookie(adbName);
29
+ }
30
+
31
+ /**
32
+ * @param {AttachedAndroidDeviceCookie} deviceCookie
33
+ * @returns {Promise<void>}
34
+ */
35
+ async postAllocate(deviceCookie) {
36
+ const { adbName } = deviceCookie;
37
+
28
38
  // TODO Also disable native animations?
29
39
  await this._adb.apiLevel(adbName);
30
40
  await this._adb.unlockScreen(adbName);
31
41
  await this._attachedAndroidLauncher.notifyLaunchCompleted(adbName);
32
- return new AttachedAndroidDeviceCookie(adbName);
33
42
  }
34
43
 
35
44
  /**
@@ -2,7 +2,7 @@ const _ = require('lodash');
2
2
 
3
3
  const DetoxRuntimeError = require('../../../../../errors/DetoxRuntimeError');
4
4
  const environment = require('../../../../../utils/environment');
5
- const logger = require('../../../../../utils/logger').child({ __filename });
5
+ const logger = require('../../../../../utils/logger').child({ cat: 'device' });
6
6
 
7
7
  const REQUIRED_EMULATOR_MAJOR = 29;
8
8
 
@@ -12,11 +12,11 @@ class AVDValidator {
12
12
  this._emulatorVersionResolver = emulatorVersionResolver;
13
13
  }
14
14
 
15
- async validate(avdName) {
15
+ async validate(avdName, isHeadless) {
16
16
  const avds = await this._avdsResolver.resolve(avdName);
17
17
  this._assertAVDs(avds);
18
18
  await this._assertAVDMatch(avds, avdName);
19
- await this._validateEmulatorVer();
19
+ await this._validateEmulatorVer(isHeadless);
20
20
  }
21
21
 
22
22
  _assertAVDs(avds) {
@@ -37,8 +37,8 @@ class AVDValidator {
37
37
  }
38
38
  }
39
39
 
40
- async _validateEmulatorVer() {
41
- const emulatorVersion = await this._emulatorVersionResolver.resolve();
40
+ async _validateEmulatorVer(isHeadless) {
41
+ const emulatorVersion = await this._emulatorVersionResolver.resolve(isHeadless);
42
42
  if (!emulatorVersion) {
43
43
  logger.warn({ event: 'AVD_VALIDATION' }, 'Emulator version detection failed (See previous logs)');
44
44
  return;
@@ -1,7 +1,6 @@
1
1
  // @ts-nocheck
2
2
  const _ = require('lodash');
3
3
 
4
- const { traceMethods } = require('../../../../../utils/trace');
5
4
  const AndroidEmulatorCookie = require('../../../../cookies/AndroidEmulatorCookie');
6
5
  const AllocationDriverBase = require('../../AllocationDriverBase');
7
6
 
@@ -22,8 +21,7 @@ class EmulatorAllocDriver extends AllocationDriverBase {
22
21
  this._emulatorVersionResolver = emulatorVersionResolver;
23
22
  this._emulatorLauncher = emulatorLauncher;
24
23
  this._allocationHelper = allocationHelper;
25
-
26
- traceMethods(this, 'device', ['_launchEmulator']);
24
+ this._launchInfo = {};
27
25
  }
28
26
 
29
27
  /**
@@ -33,25 +31,41 @@ class EmulatorAllocDriver extends AllocationDriverBase {
33
31
  async allocate(deviceConfig) {
34
32
  const avdName = deviceConfig.device.avdName;
35
33
 
36
- await this._avdValidator.validate(avdName);
34
+ await this._avdValidator.validate(avdName, deviceConfig.headless);
37
35
  await this._fixAvdConfigIniSkinNameIfNeeded(avdName, deviceConfig.headless);
38
36
 
39
37
  const allocResult = await this._allocationHelper.allocateDevice(avdName);
40
- const { adbName, placeholderPort, isRunning } = allocResult;
41
- const launchOptions = {
42
- bootArgs: deviceConfig.bootArgs,
43
- gpuMode: deviceConfig.gpuMode,
44
- headless: deviceConfig.headless,
45
- readonly: deviceConfig.readonly,
46
- port: placeholderPort,
38
+ const { adbName } = allocResult;
39
+
40
+ this._launchInfo[adbName] = {
41
+ avdName,
42
+ isRunning: allocResult.isRunning,
43
+ launchOptions: {
44
+ bootArgs: deviceConfig.bootArgs,
45
+ gpuMode: deviceConfig.gpuMode,
46
+ headless: deviceConfig.headless,
47
+ readonly: deviceConfig.readonly,
48
+ port: allocResult.placeholderPort,
49
+ },
47
50
  };
48
51
 
49
- await this._launchEmulator(avdName, adbName, isRunning, launchOptions);
50
- await this._prepareEmulator(adbName);
51
-
52
52
  return new AndroidEmulatorCookie(adbName);
53
53
  }
54
54
 
55
+ /**
56
+ * @param {AndroidEmulatorCookie} deviceCookie
57
+ * @returns {Promise<void>}
58
+ */
59
+ async postAllocate(deviceCookie) {
60
+ const { adbName } = deviceCookie;
61
+ const { avdName, isRunning, launchOptions } = this._launchInfo[adbName];
62
+
63
+ await this._emulatorLauncher.launch(avdName, adbName, isRunning, launchOptions);
64
+ await this._adb.apiLevel(adbName);
65
+ await this._adb.disableAndroidAnimations(adbName);
66
+ await this._adb.unlockScreen(adbName);
67
+ }
68
+
55
69
  /**
56
70
  * @param cookie { AndroidEmulatorCookie }
57
71
  * @param options { DeallocOptions }
@@ -72,21 +86,6 @@ class EmulatorAllocDriver extends AllocationDriverBase {
72
86
  const binaryVersion = _.get(rawBinaryVersion, 'major');
73
87
  return await patchAvdSkinConfig(avdName, binaryVersion);
74
88
  }
75
-
76
- async _launchEmulator(avdName, adbName, isRunning, options) {
77
- try {
78
- await this._emulatorLauncher.launch(avdName, adbName, isRunning, options);
79
- } catch (e) {
80
- await this._allocationHelper.deallocateDevice(adbName);
81
- throw e;
82
- }
83
- }
84
-
85
- async _prepareEmulator(adbName) {
86
- await this._adb.apiLevel(adbName);
87
- await this._adb.disableAndroidAnimations(adbName);
88
- await this._adb.unlockScreen(adbName);
89
- }
90
89
  }
91
90
 
92
91
  module.exports = EmulatorAllocDriver;
@@ -1,4 +1,4 @@
1
- const logger = require('../../../../../utils/logger').child({ __filename });
1
+ const logger = require('../../../../../utils/logger').child({ cat: 'device' });
2
2
  const DeviceAllocationHelper = require('../../../../common/drivers/DeviceAllocationHelper');
3
3
 
4
4
  const DetoxEmulatorsPortRange = {
@@ -1,7 +1,8 @@
1
1
  // @ts-nocheck
2
2
  const { DetoxRuntimeError } = require('../../../../../errors');
3
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
3
4
  const retry = require('../../../../../utils/retry');
4
- const { traceMethods } = require('../../../../../utils/trace');
5
+ const traceMethods = require('../../../../../utils/traceMethods');
5
6
  const DeviceLauncher = require('../../../../common/drivers/DeviceLauncher');
6
7
  const { LaunchCommand } = require('../../../../common/drivers/android/emulator/exec/EmulatorExec');
7
8
 
@@ -14,7 +15,7 @@ class EmulatorLauncher extends DeviceLauncher {
14
15
  super(eventEmitter);
15
16
  this._adb = adb;
16
17
  this._emulatorExec = emulatorExec;
17
- traceMethods(this, 'device', ['_awaitEmulatorBoot']);
18
+ traceMethods(log, this, ['_awaitEmulatorBoot']);
18
19
  }
19
20
 
20
21
  /**
@@ -35,7 +36,7 @@ class EmulatorLauncher extends DeviceLauncher {
35
36
  retries: 2,
36
37
  interval: 100,
37
38
  conditionFn: isUnknownEmulatorError,
38
- }, () => this._launchEmulator(avdName, launchCommand));
39
+ }, () => this._launchEmulator(avdName, launchCommand, adbName));
39
40
  }
40
41
  await this._awaitEmulatorBoot(adbName);
41
42
  await this._notifyBootEvent(adbName, avdName, !isRunning);
@@ -59,8 +60,8 @@ class EmulatorLauncher extends DeviceLauncher {
59
60
  await this._notifyShutdownCompleted(adbName);
60
61
  }
61
62
 
62
- _launchEmulator(emulatorName, launchCommand) {
63
- return launchEmulatorProcess(emulatorName, this._emulatorExec, launchCommand);
63
+ _launchEmulator(emulatorName, launchCommand, adbName) {
64
+ return launchEmulatorProcess(emulatorName, this._emulatorExec, launchCommand, this._adb, adbName);
64
65
  }
65
66
 
66
67
  async _awaitEmulatorBoot(adbName) {
@@ -1,8 +1,6 @@
1
- const log = require('../../../../../utils/logger').child({ __filename });
1
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
2
2
  const { QueryVersionCommand } = require('../../../../common/drivers/android/emulator/exec/EmulatorExec');
3
3
 
4
- const EMU_BIN_VERSION_DETECT_EV = 'EMU_BIN_VERSION_DETECT';
5
-
6
4
  class EmulatorVersionResolver {
7
5
  constructor(emulatorExec) {
8
6
  this._emulatorExec = emulatorExec;
@@ -21,18 +19,18 @@ class EmulatorVersionResolver {
21
19
  try {
22
20
  rawOutput = await this._emulatorExec.exec(new QueryVersionCommand({ headless })) || '';
23
21
  } catch (error) {
24
- log.error({ event: EMU_BIN_VERSION_DETECT_EV, success: false, error }, 'Could not detect emulator binary version', error);
22
+ log.error({ success: false, error }, 'Could not detect emulator binary version', error);
25
23
  return null;
26
24
  }
27
25
 
28
26
  const matches = rawOutput.match(/Android emulator version ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]*)/);
29
27
  if (!matches) {
30
- log.warn({ event: EMU_BIN_VERSION_DETECT_EV, success: false }, 'Could not detect emulator binary version, got:', rawOutput);
28
+ log.warn({ success: false }, 'Could not detect emulator binary version, got:', rawOutput);
31
29
  return null;
32
30
  }
33
31
 
34
32
  const version = this._parseVersionString(matches[1]);
35
- log.debug({ event: EMU_BIN_VERSION_DETECT_EV, success: true }, 'Detected emulator binary version', version);
33
+ log.debug({ success: true }, 'Detected emulator binary version', version);
36
34
  return version;
37
35
  }
38
36
 
@@ -1,29 +1,15 @@
1
1
  const fs = require('fs');
2
2
 
3
3
  const _ = require('lodash');
4
- const { Tail } = require('tail');
5
4
 
6
- const unitLogger = require('../../../../../utils/logger').child({ __filename });
5
+ const unitLogger = require('../../../../../utils/logger').child({ cat: 'device' });
7
6
 
8
- function launchEmulatorProcess(emulatorName, emulatorExec, emulatorLaunchCommand) {
7
+ function launchEmulatorProcess(emulatorName, emulatorExec, emulatorLaunchCommand, adb, adbName) {
9
8
  let childProcessOutput;
10
-
11
9
  const portName = emulatorLaunchCommand.port ? `-${emulatorLaunchCommand.port}` : '';
12
10
  const tempLog = `./${emulatorName}${portName}.log`;
13
11
  const stdout = fs.openSync(tempLog, 'a');
14
12
  const stderr = fs.openSync(tempLog, 'a');
15
- const tailOptions = {
16
- useWatchFile: true,
17
- fsWatchOptions: {
18
- interval: 1500,
19
- },
20
- };
21
- const tail = new Tail(tempLog, tailOptions)
22
- .on('line', (line) => {
23
- if (line.includes('Adb connected, start proxing data')) {
24
- childProcessPromise._cpResolve();
25
- }
26
- });
27
13
 
28
14
  function detach() {
29
15
  if (childProcessOutput) {
@@ -32,7 +18,6 @@ function launchEmulatorProcess(emulatorName, emulatorExec, emulatorLaunchCommand
32
18
 
33
19
  childProcessOutput = fs.readFileSync(tempLog, 'utf8');
34
20
 
35
- tail.unwatch();
36
21
  fs.closeSync(stdout);
37
22
  fs.closeSync(stderr);
38
23
  fs.unlink(tempLog, _.noop);
@@ -46,6 +31,8 @@ function launchEmulatorProcess(emulatorName, emulatorExec, emulatorLaunchCommand
46
31
 
47
32
  log = log.child({ child_pid: childProcessPromise.childProcess.pid });
48
33
 
34
+ adb.waitForDevice(adbName).then(() => childProcessPromise._cpResolve());
35
+
49
36
  return childProcessPromise.then(() => true).catch((err) => {
50
37
  detach();
51
38
 
@@ -1,22 +1,25 @@
1
- // @ts-nocheck
2
- const DetoxRuntimeError = require('../../../../../errors/DetoxRuntimeError');
1
+ const { DetoxRuntimeError } = require('../../../../../errors');
2
+ const Timer = require('../../../../../utils/Timer');
3
3
  const GenycloudEmulatorCookie = require('../../../../cookies/GenycloudEmulatorCookie');
4
4
  const AllocationDriverBase = require('../../AllocationDriverBase');
5
5
 
6
6
  class GenyAllocDriver extends AllocationDriverBase {
7
7
 
8
8
  /**
9
- * @param adb { ADB }
10
- * @param recipeQuerying { GenyRecipeQuerying }
11
- * @param allocationHelper { GenyInstanceAllocationHelper }
12
- * @param instanceLauncher { GenyInstanceLauncher }
9
+ * @param {object} options
10
+ * @param {import('../../../../common/drivers/android/exec/ADB')} options.adb
11
+ * @param {import('./GenyRecipeQuerying')} options.recipeQuerying
12
+ * @param {import('./GenyInstanceAllocationHelper')} options.allocationHelper
13
+ * @param {import('./GenyInstanceLauncher')} options.instanceLauncher
13
14
  */
14
15
  constructor({ adb, recipeQuerying, allocationHelper, instanceLauncher }) {
15
16
  super();
17
+
16
18
  this._adb = adb;
17
19
  this._recipeQuerying = recipeQuerying;
18
20
  this._instanceLauncher = instanceLauncher;
19
21
  this._instanceAllocationHelper = allocationHelper;
22
+ this._launchInfo = {};
20
23
  }
21
24
 
22
25
  /**
@@ -28,20 +31,26 @@ class GenyAllocDriver extends AllocationDriverBase {
28
31
  const recipe = await this._recipeQuerying.getRecipeFromQuery(deviceQuery);
29
32
  this._assertRecipe(deviceQuery, recipe);
30
33
 
31
- const allocResult = await this._instanceAllocationHelper.allocateDevice(recipe);
32
- let { instance, isNew } = allocResult;
34
+ const { instance, isNew } = await this._instanceAllocationHelper.allocateDevice(recipe);
35
+ this._launchInfo[instance.uuid] = { isNew };
36
+ return new GenycloudEmulatorCookie(instance);
37
+ }
33
38
 
34
- try {
35
- instance = await this._instanceLauncher.launch(instance, isNew);
36
- } catch (e) {
37
- await this._instanceAllocationHelper.deallocateDevice(instance.uuid);
38
- throw e;
39
- }
40
- const { adbName } = instance;
39
+ /**
40
+ * @param {GenycloudEmulatorCookie} cookie
41
+ * @returns {Promise<void>}
42
+ */
43
+ async postAllocate(cookie) {
44
+ const { instance } = cookie;
45
+ const { isNew } = this._launchInfo[instance.uuid];
46
+ const readyInstance = cookie.instance = await this._instanceLauncher.launch(instance, isNew);
41
47
 
42
- await this._adb.disableAndroidAnimations(adbName);
43
- await this._adb.apiLevel(adbName);
44
- return new GenycloudEmulatorCookie(instance);
48
+ const { adbName } = readyInstance;
49
+ await Timer.run(20000, 'waiting for device to respond', async () => {
50
+ await this._adb.disableAndroidAnimations(adbName);
51
+ await this._adb.setWiFiToggle(adbName, true);
52
+ await this._adb.apiLevel(adbName);
53
+ });
45
54
  }
46
55
 
47
56
  /**
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- const logger = require('../../../../../utils/logger').child({ __filename });
2
+ const logger = require('../../../../../utils/logger').child({ cat: 'device' });
3
3
  const DeviceAllocationHelper = require('../../../../common/drivers/DeviceAllocationHelper');
4
4
 
5
5
  const { ALLOCATE_DEVICE_LOG_EVT } = DeviceAllocationHelper;
@@ -16,6 +16,7 @@ class SimulatorAllocDriver extends AllocationDriverBase {
16
16
  this._deviceRegistry = deviceRegistry;
17
17
  this._applesimutils = applesimutils;
18
18
  this._simulatorLauncher = simulatorLauncher;
19
+ this._launchInfo = {};
19
20
  }
20
21
 
21
22
  /**
@@ -35,16 +36,20 @@ class SimulatorAllocDriver extends AllocationDriverBase {
35
36
  throw new DetoxRuntimeError(`Failed to find device matching ${deviceComment}`);
36
37
  }
37
38
 
38
- try {
39
- await this._simulatorLauncher.launch(udid, deviceConfig.type, deviceConfig.bootArgs, deviceConfig.headless);
40
- } catch (e) {
41
- await this._deviceRegistry.disposeDevice(udid);
42
- throw e;
43
- }
44
-
39
+ this._launchInfo[udid] = { deviceConfig };
45
40
  return new IosSimulatorCookie(udid);
46
41
  }
47
42
 
43
+ /**
44
+ * @param {IosSimulatorCookie} deviceCookie
45
+ * @returns {Promise<void>}
46
+ */
47
+ async postAllocate(deviceCookie) {
48
+ const { udid } = deviceCookie;
49
+ const { deviceConfig } = this._launchInfo[udid];
50
+ await this._simulatorLauncher.launch(udid, deviceConfig.type, deviceConfig.bootArgs, deviceConfig.headless);
51
+ }
52
+
48
53
  /**
49
54
  * @param cookie { IosSimulatorCookie }
50
55
  * @param options { DeallocOptions }
@@ -16,7 +16,7 @@ class DeviceAllocatorFactory {
16
16
  * @returns { AllocationDriverBase }
17
17
  * @private
18
18
  */
19
- _createDriver(deps) {} // eslint-disable-line no-unused-vars
19
+ _createDriver(deps) {} // eslint-disable-line @typescript-eslint/no-unused-vars
20
20
  }
21
21
 
22
22
  module.exports = DeviceAllocatorFactory;
@@ -189,6 +189,10 @@ class ADB {
189
189
  }
190
190
  }
191
191
 
192
+ async waitForDevice(deviceId) {
193
+ return await this.adbCmd(deviceId, 'wait-for-device');
194
+ }
195
+
192
196
  async apiLevel(deviceId) {
193
197
  if (this._cachedApiLevels.has(deviceId)) {
194
198
  return this._cachedApiLevels.get(deviceId);
@@ -206,6 +210,11 @@ class ADB {
206
210
  await this.shell(deviceId, `settings put global transition_animation_scale 0`);
207
211
  }
208
212
 
213
+ async setWiFiToggle(deviceId, state) {
214
+ const value = (state === true ? 'enable' : 'disable');
215
+ await this.shell(deviceId, `svc wifi ${value}`);
216
+ }
217
+
209
218
  async screencap(deviceId, path) {
210
219
  await this.shell(deviceId, `screencap ${path}`);
211
220
  }
@@ -28,7 +28,7 @@ class GenyCloudExec {
28
28
  }
29
29
 
30
30
  startInstance(recipeUUID, instanceName) {
31
- return this._exec(`instances start --stop-when-inactive --no-wait ${recipeUUID} "${instanceName}"`, { retries: 0 });
31
+ return this._exec(`instances start --no-wait ${recipeUUID} "${instanceName}"`, { retries: 0 });
32
32
  }
33
33
 
34
34
  adbConnect(instanceUUID) {
@@ -1,9 +1,9 @@
1
- const session = () => require('../../../../../../../internals').session;
1
+ const internals = () => require('../../../../../../../internals');
2
2
 
3
3
  class GenyInstanceNaming {
4
4
  generateName() {
5
- const { id, workerId } = session();
6
- return `Detox.${id}.${workerId}`;
5
+ const { session, worker } = internals();
6
+ return `Detox.${session.id}.${worker.id}`;
7
7
  }
8
8
 
9
9
  isFamilial(name) {
@@ -1,4 +1,4 @@
1
- const logger = require('../../../../../../utils/logger').child({ __filename });
1
+ const logger = require('../../../../../../utils/logger').child({ cat: 'device' });
2
2
 
3
3
  const Recipe = require('./dto/GenyRecipe');
4
4
 
@@ -1,13 +1,13 @@
1
1
  // TODO Tweak such that if apk's already exist on the device (need to store uniquely), they will not be resent (would optimize cloud, for example)
2
2
 
3
3
  class AppInstallHelper {
4
- constructor(adb, fileXfer) {
4
+ constructor(adb, fileTransfer) {
5
5
  this._adb = adb;
6
- this._fileXfer = fileXfer;
6
+ this._fileTransfer = fileTransfer;
7
7
  }
8
8
 
9
9
  async install(deviceId, appBinaryPath, testBinaryPath) {
10
- await this._fileXfer.prepareDestinationDir(deviceId);
10
+ await this._fileTransfer.prepareDestinationDir(deviceId);
11
11
  await this._pushAndInstallBinary(deviceId, appBinaryPath, 'Application.apk');
12
12
  if (testBinaryPath) {
13
13
  await this._pushAndInstallBinary(deviceId, testBinaryPath, 'Test.apk');
@@ -15,7 +15,7 @@ class AppInstallHelper {
15
15
  }
16
16
 
17
17
  async _pushAndInstallBinary(deviceId, binaryPath, binaryFilenameOnTarget) {
18
- const binaryPathOnTarget = await this._fileXfer.send(deviceId, binaryPath, binaryFilenameOnTarget);
18
+ const binaryPathOnTarget = await this._fileTransfer.send(deviceId, binaryPath, binaryFilenameOnTarget);
19
19
  await this._adb.remoteInstall(deviceId, binaryPathOnTarget);
20
20
  }
21
21
  }
@@ -5,7 +5,7 @@ const path = require('path');
5
5
  const fs = require('fs-extra');
6
6
  const Telnet = require('telnet-client');
7
7
 
8
- const log = require('../../../../../utils/logger').child({ __filename });
8
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
9
9
 
10
10
  class EmulatorTelnet {
11
11
  constructor() {
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
2
 
3
- class FileXfer {
3
+ class FileTransfer {
4
4
  constructor(adb, destinationDir) {
5
5
  this._adb = adb;
6
6
  this._dir = destinationDir;
@@ -18,4 +18,4 @@ class FileXfer {
18
18
  }
19
19
  }
20
20
 
21
- module.exports = FileXfer;
21
+ module.exports = FileTransfer;
@@ -1,4 +1,4 @@
1
- const log = require('../../../../../utils/logger').child({ __filename });
1
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
2
2
 
3
3
  const DEVICE_LOOKUP_LOG_EVT = 'DEVICE_LOOKUP';
4
4
 
@@ -77,7 +77,7 @@ class MonitoredInstrumentation {
77
77
  'while it was waiting for "ready" message (over WebSocket) ' +
78
78
  'from the instrumentation process.',
79
79
  debugInfo: this.instrumentationStackTrace
80
- ? `Native stacktrace dump: ${this.instrumentationStackTrace}`
80
+ ? `Native stacktrace dump:\n${this.instrumentationStackTrace}`
81
81
  : '',
82
82
  });
83
83
  }
@@ -0,0 +1,14 @@
1
+ const FileTransfer = require('./FileTransfer');
2
+
3
+ const FILE_PATH = '/data/local/tmp/detox';
4
+
5
+ class TempFileTransfer extends FileTransfer {
6
+ constructor(adb) {
7
+ super(adb, FILE_PATH);
8
+ }
9
+ }
10
+
11
+ module.exports = {
12
+ TempFileTransfer,
13
+ FILE_PATH
14
+ };