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
@@ -409,7 +409,7 @@ Please check your Detox config${this._atPath()}`,
409
409
  case 'gpuMode':
410
410
  return this._unsupportedPropertyByDeviceType('gpuMode', ['android.emulator'], deviceAlias);
411
411
  case 'headless':
412
- return this._unsupportedPropertyByDeviceType('headless', ['android.emulator'], deviceAlias);
412
+ return this._unsupportedPropertyByDeviceType('headless', ['ios.simulator', 'android.emulator'], deviceAlias);
413
413
  case 'readonly':
414
414
  return this._unsupportedPropertyByDeviceType('readonly', ['android.emulator'], deviceAlias);
415
415
  case 'utilBinaryPaths':
@@ -507,6 +507,14 @@ Examine your Detox config${this._atPath()}`,
507
507
  });
508
508
  }
509
509
 
510
+ unsupportedReversePorts(appPath) {
511
+ return new DetoxConfigError({
512
+ message: `Non-Android app configs cannot have "reversePorts" property:`,
513
+ debugInfo: this._focusOnAppConfig(appPath),
514
+ inspectOptions: { depth: 4 },
515
+ });
516
+ }
517
+
510
518
  missingAppBinaryPath(appPath) {
511
519
  return new DetoxConfigError({
512
520
  message: `Missing "binaryPath" property in the app config.\nExpected a string:`,
@@ -656,12 +664,19 @@ Examine your Detox config${this._atPath()}`,
656
664
  }
657
665
 
658
666
  invalidTestRunnerProperty(isGlobal) {
667
+ const testRunner = _.get(
668
+ isGlobal
669
+ ? this.contents
670
+ : this._getSelectedConfiguration(),
671
+ ['testRunner']
672
+ );
673
+
659
674
  return new DetoxConfigError({
660
- message: `testRunner should be an object, not a string`,
675
+ message: `testRunner should be an object, not a ${typeof testRunner}`,
661
676
  hint: `Check that in your Detox config${this._atPath()}`,
662
677
  inspectOptions: { depth: isGlobal ? 0 : 3 },
663
678
  debugInfo: isGlobal ? {
664
- testRunner: _.get(this.contents, ['testRunner']),
679
+ testRunner,
665
680
  ...this.contents,
666
681
  } : {
667
682
  ...this._focusOnConfiguration(c => _.pick(c, ['testRunner'])),
@@ -8,6 +8,10 @@ class DetoxError extends Error {
8
8
  this.name = 'DetoxError';
9
9
  }
10
10
 
11
+ format() {
12
+ return this.message;
13
+ }
14
+
11
15
  static get reportIssue() {
12
16
  return 'Please report this issue on our GitHub tracker:\nhttps://github.com/wix/Detox/issues';
13
17
  }
@@ -32,7 +36,7 @@ class DetoxError extends Error {
32
36
  */
33
37
  static format(err, inspectOptions = { depth: 1 }) {
34
38
  if (err instanceof DetoxError) {
35
- return err.message;
39
+ return err.format();
36
40
  }
37
41
 
38
42
  if (_.isError(err) && /^Command failed:/.test(err.message)) {
@@ -1,4 +1,5 @@
1
1
  // @ts-nocheck
2
+ const assert = require('assert');
2
3
  const path = require('path');
3
4
 
4
5
  const fs = require('fs-extra');
@@ -6,6 +7,10 @@ const _ = require('lodash');
6
7
  const tempfile = require('tempfile');
7
8
 
8
9
  const { assertEnum, assertNormalized } = require('../utils/assertArgument');
10
+ const { removeMilliseconds } = require('../utils/dateUtils');
11
+ const { actionDescription, expectDescription } = require('../utils/invocationTraceDescriptions');
12
+ const log = require('../utils/logger').child({ cat: 'ws-client, ws' });
13
+ const traceInvocationCall = require('../utils/traceInvocationCall').bind(null, log);
9
14
 
10
15
  const assertDirection = assertEnum(['left', 'right', 'up', 'down']);
11
16
  const assertSpeed = assertEnum(['fast', 'slow']);
@@ -23,7 +28,8 @@ class Expect {
23
28
  + (percent + (' (' + (typeof percent + ')'))));
24
29
  }
25
30
 
26
- return this.expect('toBeVisible', percent);
31
+ const traceDescription = expectDescription.toBeVisible(percent);
32
+ return this.expect('toBeVisible', traceDescription, percent);
27
33
  }
28
34
 
29
35
  toBeNotVisible() {
@@ -31,7 +37,8 @@ class Expect {
31
37
  }
32
38
 
33
39
  toBeFocused() {
34
- return this.expect('toBeFocused');
40
+ const traceDescription = expectDescription.toBeFocused();
41
+ return this.expect('toBeFocused', traceDescription);
35
42
  }
36
43
 
37
44
  toBeNotFocused() {
@@ -39,7 +46,8 @@ class Expect {
39
46
  }
40
47
 
41
48
  toExist() {
42
- return this.expect('toExist');
49
+ const traceDescription = expectDescription.toExist();
50
+ return this.expect('toExist', traceDescription);
43
51
  }
44
52
 
45
53
  toNotExist() {
@@ -47,7 +55,8 @@ class Expect {
47
55
  }
48
56
 
49
57
  toHaveText(text) {
50
- return this.expect('toHaveText', text);
58
+ const traceDescription = expectDescription.toHaveText(text);
59
+ return this.expect('toHaveText', traceDescription, text);
51
60
  }
52
61
 
53
62
  toNotHaveText(text) {
@@ -55,7 +64,8 @@ class Expect {
55
64
  }
56
65
 
57
66
  toHaveLabel(label) {
58
- return this.expect('toHaveLabel', label);
67
+ const traceDescription = expectDescription.toHaveLabel(label);
68
+ return this.expect('toHaveLabel', traceDescription, label);
59
69
  }
60
70
 
61
71
  toNotHaveLabel(label) {
@@ -63,7 +73,8 @@ class Expect {
63
73
  }
64
74
 
65
75
  toHaveId(id) {
66
- return this.expect('toHaveId', id);
76
+ const traceDescription = expectDescription.toHaveId(id);
77
+ return this.expect('toHaveId', traceDescription, id);
67
78
  }
68
79
 
69
80
  toNotHaveId(id) {
@@ -71,7 +82,8 @@ class Expect {
71
82
  }
72
83
 
73
84
  toHaveValue(value) {
74
- return this.expect('toHaveValue', value);
85
+ const traceDescription = expectDescription.toHaveValue(value);
86
+ return this.expect('toHaveValue', traceDescription, value);
75
87
  }
76
88
 
77
89
  toNotHaveValue(value) {
@@ -79,7 +91,8 @@ class Expect {
79
91
  }
80
92
 
81
93
  toHaveSliderPosition(position, tolerance = 0) {
82
- return this.expect('toHaveSliderPosition', position, tolerance);
94
+ const traceDescription = expectDescription.toHaveSliderPosition(position, tolerance);
95
+ return this.expect('toHaveSliderPosition', traceDescription, position, tolerance);
83
96
  }
84
97
 
85
98
  toHaveToggleValue(value) {
@@ -103,16 +116,18 @@ class Expect {
103
116
  };
104
117
  }
105
118
 
106
- expect(expectation, ...params) {
119
+ expect(expectation, traceDescription, ...params) {
120
+ assert(traceDescription, `must provide trace description for expectation: \n ${JSON.stringify(expectation)}`);
121
+
107
122
  const invocation = this.createInvocation(expectation, ...params);
108
- return this._invocationManager.execute(invocation);
123
+ traceDescription = expectDescription.full(traceDescription, this.modifiers.includes('not'));
124
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
109
125
  }
110
126
  }
111
127
 
112
128
  class InternalExpect extends Expect {
113
- expect(expectation, ...params) {
114
- const invocation = this.createInvocation(expectation, ...params);
115
- return invocation;
129
+ expect(expectation, _traceDescription, ...params) {
130
+ return this.createInvocation(expectation, ...params);
116
131
  }
117
132
  }
118
133
 
@@ -131,7 +146,8 @@ class Element {
131
146
  }
132
147
 
133
148
  getAttributes() {
134
- return this.withAction('getAttributes');
149
+ const traceDescription = actionDescription.getAttributes();
150
+ return this.withAction('getAttributes', traceDescription);
135
151
  }
136
152
 
137
153
  tap(point) {
@@ -140,12 +156,16 @@ class Element {
140
156
  if (typeof point.x !== 'number') throw new Error('point.x should be a number, but got ' + (point.x + (' (' + (typeof point.x + ')'))));
141
157
  if (typeof point.y !== 'number') throw new Error('point.y should be a number, but got ' + (point.y + (' (' + (typeof point.y + ')'))));
142
158
  }
143
- return this.withAction('tap', point);
159
+
160
+ const traceDescription = actionDescription.tapAtPoint(point);
161
+ return this.withAction('tap', traceDescription, point);
144
162
  }
145
163
 
146
164
  longPress(duration = 1000) {
147
165
  if (typeof duration !== 'number') throw new Error('duration should be a number, but got ' + (duration + (' (' + (typeof duration + ')'))));
148
- return this.withAction('longPress', duration);
166
+
167
+ const traceDescription = actionDescription.longPress(duration);
168
+ return this.withAction('longPress', traceDescription, duration);
149
169
  }
150
170
 
151
171
  longPressAndDrag(duration, normalizedPositionX, normalizedPositionY, targetElement,
@@ -162,13 +182,18 @@ class Element {
162
182
  assertNormalized({ normalizedTargetPositionX });
163
183
  assertNormalized({ normalizedTargetPositionY });
164
184
 
165
- return this.withActionAndTargetElement('longPress', targetElement, duration, normalizedPositionX, normalizedPositionY,
185
+ const traceDescription = actionDescription.longPressAndDrag(duration, normalizedPositionX, normalizedPositionY, targetElement,
186
+ normalizedTargetPositionX, normalizedTargetPositionY, speed, holdDuration);
187
+ return this.withActionAndTargetElement('longPress', targetElement, traceDescription, duration, normalizedPositionX, normalizedPositionY,
166
188
  normalizedTargetPositionX, normalizedTargetPositionY, speed, holdDuration);
167
189
  }
168
190
 
169
191
  multiTap(times) {
170
192
  if (typeof times !== 'number') throw new Error('times should be a number, but got ' + (times + (' (' + (typeof times + ')'))));
171
- return this.withAction('multiTap', times);
193
+ if (times < 1) throw new Error('times should be greater than 0, but got ' + times);
194
+
195
+ const traceDescription = actionDescription.multiTap(times);
196
+ return this.withAction('multiTap', traceDescription, times);
172
197
  }
173
198
 
174
199
  tapAtPoint(point) {
@@ -176,25 +201,39 @@ class Element {
176
201
  }
177
202
 
178
203
  tapBackspaceKey() {
179
- return this.withAction('tapBackspaceKey');
204
+ const traceDescription = actionDescription.tapBackspaceKey();
205
+ return this.withAction('tapBackspaceKey', traceDescription);
180
206
  }
181
207
 
182
208
  tapReturnKey() {
183
- return this.withAction('tapReturnKey');
209
+ const traceDescription = actionDescription.tapReturnKey();
210
+ return this.withAction('tapReturnKey', traceDescription);
184
211
  }
185
212
 
186
213
  typeText(text) {
187
214
  if (typeof text !== 'string') throw new Error('text should be a string, but got ' + (text + (' (' + (typeof text + ')'))));
188
- return this.withAction('typeText', text);
215
+
216
+ const traceDescription = actionDescription.typeText(text);
217
+ return this.withAction('typeText', traceDescription, text);
189
218
  }
190
219
 
191
220
  replaceText(text) {
192
221
  if (typeof text !== 'string') throw new Error('text should be a string, but got ' + (text + (' (' + (typeof text + ')'))));
193
- return this.withAction('replaceText', text);
222
+
223
+ const traceDescription = actionDescription.replaceText(text);
224
+ return this.withAction('replaceText', traceDescription, text);
194
225
  }
195
226
 
196
227
  clearText() {
197
- return this.withAction('clearText');
228
+ const traceDescription = actionDescription.clearText();
229
+ return this.withAction('clearText', traceDescription);
230
+ }
231
+
232
+ performAccessibilityAction(actionName) {
233
+ if (typeof actionName !== 'string') throw new Error('actionName should be a string, but got ' + (actionName + (' (' + (typeof actionName + ')'))));
234
+
235
+ const traceDescription = actionDescription.performAccessibilityAction(actionName);
236
+ return this.withAction('accessibilityAction', traceDescription, actionName);
198
237
  }
199
238
 
200
239
  scroll(pixels, direction = 'down', startPositionX = NaN, startPositionY = NaN) {
@@ -202,12 +241,15 @@ class Element {
202
241
  if (typeof pixels !== 'number') throw new Error('amount of pixels should be a number, but got ' + (pixels + (' (' + (typeof pixels + ')'))));
203
242
  if (typeof startPositionX !== 'number') throw new Error('startPositionX should be a number, but got ' + (startPositionX + (' (' + (typeof startPositionX + ')'))));
204
243
  if (typeof startPositionY !== 'number') throw new Error('startPositionY should be a number, but got ' + (startPositionY + (' (' + (typeof startPositionY + ')'))));
205
- return this.withAction('scroll', pixels, direction, startPositionX, startPositionY);
244
+
245
+ const traceDescription = actionDescription.scroll(pixels, direction, startPositionX, startPositionY);
246
+ return this.withAction('scroll', traceDescription, pixels, direction, startPositionX, startPositionY);
206
247
  }
207
248
 
208
249
  scrollTo(edge) {
209
250
  if (!['left', 'right', 'top', 'bottom'].some(option => option === edge)) throw new Error('edge should be one of [left, right, top, bottom], but got ' + edge);
210
- return this.withAction('scrollTo', edge);
251
+ const traceDescription = actionDescription.scrollTo(edge);
252
+ return this.withAction('scrollTo', traceDescription, edge);
211
253
  }
212
254
 
213
255
  swipe(direction, speed = 'fast', normalizedSwipeOffset = NaN, normalizedStartingPointX = NaN, normalizedStartingPointY = NaN) {
@@ -218,42 +260,65 @@ class Element {
218
260
  assertNormalized({ normalizedStartingPointY });
219
261
 
220
262
  normalizedSwipeOffset = Number.isNaN(normalizedSwipeOffset) ? 0.75 : normalizedSwipeOffset;
221
- return this.withAction('swipe', direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
263
+ const traceDescription = actionDescription.swipe(direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
264
+ return this.withAction(
265
+ 'swipe',
266
+ traceDescription,
267
+ direction,
268
+ speed,
269
+ normalizedSwipeOffset,
270
+ normalizedStartingPointX,
271
+ normalizedStartingPointY
272
+ );
222
273
  }
223
274
 
224
275
  setColumnToValue(column, value) {
225
276
  if (typeof column !== 'number') throw new Error('column should be a number, but got ' + (column + (' (' + (typeof column + ')'))));
226
277
  if (typeof value !== 'string') throw new Error('value should be a string, but got ' + (value + (' (' + (typeof value + ')'))));
227
- return this.withAction('setColumnToValue', column, value);
278
+
279
+ const traceDescription = actionDescription.setColumnToValue(column, value);
280
+ return this.withAction('setColumnToValue', traceDescription, column, value);
228
281
  }
229
282
 
230
283
  setDatePickerDate(dateString, dateFormat) {
231
284
  if (typeof dateString !== 'string') throw new Error('dateString should be a string, but got ' + (dateString + (' (' + (typeof dateString + ')'))));
232
285
  if (typeof dateFormat !== 'string') throw new Error('dateFormat should be a string, but got ' + (dateFormat + (' (' + (typeof dateFormat + ')'))));
233
- return this.withAction('setDatePickerDate', dateString, dateFormat);
286
+ if (dateFormat === 'ISO8601') {
287
+ dateString = removeMilliseconds(dateString);
288
+ }
289
+
290
+ const traceDescription = actionDescription.setDatePickerDate(dateString, dateFormat);
291
+ return this.withAction('setDatePickerDate', traceDescription, dateString, dateFormat);
234
292
  }
235
293
 
236
294
  pinch(scale, speed = 'fast', angle = 0) {
237
295
  if (typeof scale !== 'number' || !Number.isFinite(scale) || scale < 0) throw new Error(`pinch scale must be a finite number larger than zero`);
238
296
  if (!['slow', 'fast'].includes(speed)) throw new Error(`pinch speed is either 'slow' or 'fast'`);
239
297
  if (typeof angle !== 'number' || !Number.isFinite(angle)) throw new Error(`pinch angle must be a finite number (radian)`);
240
- return this.withAction('pinch', scale, speed, angle);
298
+
299
+ const traceDescription = actionDescription.pinch(scale, speed, angle);
300
+ return this.withAction('pinch', traceDescription, scale, speed, angle);
241
301
  }
242
302
 
243
303
  pinchWithAngle(direction, speed = 'slow', angle = 0) {
244
304
  if (!['inward', 'outward'].includes(direction)) throw new Error(`pinchWithAngle direction is either 'inward' or 'outward'`);
245
305
  if (!['slow', 'fast'].includes(speed)) throw new Error(`pinchWithAngle speed is either 'slow' or 'fast'`);
246
306
  if (typeof angle !== 'number') throw new Error(`pinchWithAngle angle must be a number (radiant), got ${typeof angle}`);
247
- return this.withAction('pinchWithAngle', direction, speed, angle);
307
+
308
+ const traceDescription = actionDescription.pinchWithAngle(direction, speed, angle);
309
+ return this.withAction('pinchWithAngle', traceDescription, direction, speed, angle);
248
310
  }
249
311
 
250
312
  adjustSliderToPosition(position) {
251
313
  if (!(typeof position === 'number' && position >= 0 && position <= 1)) throw new Error('position should be a number [0.0, 1.0], but got ' + (position + (' (' + (typeof position + ')'))));
252
- return this.withAction('adjustSliderToPosition', position);
314
+
315
+ const traceDescription = actionDescription.adjustSliderToPosition(position);
316
+ return this.withAction('adjustSliderToPosition', traceDescription, position);
253
317
  }
254
318
 
255
319
  async takeScreenshot(fileName) {
256
- const { screenshotPath } = await this.withAction('takeScreenshot', fileName);
320
+ const traceDescription = actionDescription.takeScreenshot(fileName);
321
+ const { screenshotPath } = await this.withAction('takeScreenshot', traceDescription, fileName);
257
322
 
258
323
  const filePath = tempfile('.detox.element-screenshot.png');
259
324
  await fs.move(screenshotPath, filePath);
@@ -287,22 +352,20 @@ class Element {
287
352
  return invocation;
288
353
  }
289
354
 
290
- withAction(action, ...params) {
355
+ withAction(action, traceDescription, ...params) {
291
356
  const invocation = this.createInvocation(action, null, ...params);
292
- return this._invocationManager.execute(invocation);
357
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
293
358
  }
294
359
 
295
- withActionAndTargetElement(action, targetElement, ...params) {
360
+ withActionAndTargetElement(action, targetElement, traceDescription, ...params) {
296
361
  const invocation = this.createInvocation(action, targetElement, ...params);
297
- return this._invocationManager.execute(invocation);
362
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
298
363
  }
299
364
  }
300
365
 
301
366
  class InternalElement extends Element {
302
-
303
- withAction(action, ...params) {
304
- const invocation = this.createInvocation(action, null, ...params);
305
- return invocation;
367
+ withAction(action, _traceDescription, ...params) {
368
+ return this.createInvocation(action, null, ...params);
306
369
  }
307
370
  }
308
371
 
@@ -341,7 +404,6 @@ class By {
341
404
  }
342
405
 
343
406
  class Matcher {
344
-
345
407
  accessibilityLabel(label) {
346
408
  return this.label(label);
347
409
  }
@@ -387,32 +449,38 @@ class Matcher {
387
449
  throwMatcherError(matcher);
388
450
  }
389
451
 
390
- this.and({ predicate: { type: 'ancestor', predicate: matcher.predicate } });
391
- return this;
452
+ return this.and({ predicate: { type: 'ancestor', predicate: matcher.predicate } });
392
453
  }
393
454
 
394
455
  withDescendant(matcher) {
395
456
  if (!(matcher instanceof Matcher)) {
396
457
  throwMatcherError(matcher);
397
458
  }
398
- this.and({ predicate: { type: 'descendant', predicate: matcher.predicate } });
399
- return this;
459
+
460
+ return this.and({ predicate: { type: 'descendant', predicate: matcher.predicate } });
400
461
  }
401
462
 
402
463
  and(matcher) {
403
- // if (!(matcher instanceof Matcher)) {
404
- // throwMatcherError(matcher);
405
- // }
406
- const tempPredicate = this.predicate;
407
- delete this.predicate;
408
- this.predicate = { type: 'and', predicates: [] };
409
- this.predicate.predicates.push(tempPredicate);
464
+ const result = new Matcher();
465
+
466
+ result.predicate = {
467
+ type: 'and',
468
+ predicates: [
469
+ ...Matcher.predicates(this),
470
+ ...Matcher.predicates(matcher),
471
+ ].map(x => _.cloneDeep(x))
472
+ };
473
+
474
+ return result;
475
+ }
476
+
477
+ /** @private */
478
+ static *predicates(matcher) {
410
479
  if (matcher.predicate.type === 'and') {
411
- this.predicate.predicates = this.predicate.predicates.concat(matcher.predicate.predicates);
480
+ yield* matcher.predicate.predicates;
412
481
  } else {
413
- this.predicate.predicates.push(matcher.predicate);
482
+ yield matcher.predicate;
414
483
  }
415
- return this;
416
484
  }
417
485
  }
418
486
 
@@ -484,6 +552,16 @@ class WaitFor {
484
552
  return this;
485
553
  }
486
554
 
555
+ toBeFocused() {
556
+ this.expectation = this.expectation.toBeFocused();
557
+ return this;
558
+ }
559
+
560
+ toBeNotFocused() {
561
+ this.expectation = this.expectation.toBeNotFocused();
562
+ return this;
563
+ }
564
+
487
565
  get not() {
488
566
  this.expectation.not;
489
567
  return this;
@@ -493,7 +571,9 @@ class WaitFor {
493
571
  if (typeof timeout !== 'number') throw new Error('text should be a number, but got ' + (timeout + (' (' + (typeof timeout + ')'))));
494
572
  if (timeout < 0) throw new Error('timeout must be larger than 0');
495
573
  this.timeout = timeout;
496
- return this.waitForWithTimeout();
574
+
575
+ const traceDescription = expectDescription.withTimeout(timeout);
576
+ return this.waitForWithTimeout(traceDescription);
497
577
  }
498
578
 
499
579
  whileElement(matcher) {
@@ -504,106 +584,143 @@ class WaitFor {
504
584
 
505
585
  tap(point) {
506
586
  this.action = this.actionableElement.tap(point);
507
- return this.waitForWithAction();
587
+ const traceDescription = actionDescription.tapAtPoint(point);
588
+ return this.waitForWithAction(traceDescription);
508
589
  }
509
590
 
510
591
  longPress(duration) {
511
592
  this.action = this.actionableElement.longPress(duration);
512
- return this.waitForWithAction();
593
+ const traceDescription = actionDescription.longPress(duration);
594
+ return this.waitForWithAction(traceDescription);
513
595
  }
514
596
 
515
597
  multiTap(times) {
516
598
  this.action = this.actionableElement.multiTap(times);
517
- return this.waitForWithAction();
599
+ const traceDescription = actionDescription.multiTap(times);
600
+ return this.waitForWithAction(traceDescription);
518
601
  }
519
602
 
520
603
  tapAtPoint(point) {
521
604
  this.action = this.actionableElement.tap(point);
522
- return this.waitForWithAction();
605
+ const traceDescription = actionDescription.tapAtPoint(point);
606
+ return this.waitForWithAction(traceDescription);
523
607
  }
524
608
 
525
609
  tapBackspaceKey() {
526
610
  this.action = this.actionableElement.tapBackspaceKey();
527
- return this.waitForWithAction();
611
+ const traceDescription = actionDescription.tapBackspaceKey();
612
+ return this.waitForWithAction(traceDescription);
528
613
  }
529
614
 
530
615
  tapReturnKey() {
531
616
  this.action = this.actionableElement.tapReturnKey();
532
- return this.waitForWithAction();
617
+ const traceDescription = actionDescription.tapReturnKey();
618
+ return this.waitForWithAction(traceDescription);
533
619
  }
534
620
 
535
621
  typeText(text) {
536
622
  this.action = this.actionableElement.typeText(text);
537
- return this.waitForWithAction();
623
+ const traceDescription = actionDescription.typeText(text);
624
+ return this.waitForWithAction(traceDescription);
538
625
  }
539
626
 
540
627
  replaceText(text) {
541
628
  this.action = this.actionableElement.replaceText(text);
542
- return this.waitForWithAction();
629
+ const traceDescription = actionDescription.replaceText(text);
630
+ return this.waitForWithAction(traceDescription);
543
631
  }
544
632
 
545
633
  clearText() {
546
634
  this.action = this.actionableElement.clearText();
547
- return this.waitForWithAction();
635
+ const traceDescription = actionDescription.clearText();
636
+ return this.waitForWithAction(traceDescription);
548
637
  }
549
638
 
550
639
  scroll(pixels, direction, startPositionX, startPositionY) {
551
640
  this.action = this.actionableElement.scroll(pixels, direction, startPositionX, startPositionY);
552
- return this.waitForWithAction();
641
+
642
+ const traceDescription = actionDescription.scroll(pixels, direction, startPositionX, startPositionY);
643
+ return this.waitForWithAction(traceDescription);
553
644
  }
554
645
 
555
646
  scrollTo(edge) {
556
647
  this.action = this.actionableElement.scrollTo(edge);
557
- return this.waitForWithAction();
648
+ const traceDescription = actionDescription.scrollTo(edge);
649
+ return this.waitForWithAction(traceDescription);
558
650
  }
559
651
 
560
652
  swipe(direction, speed, percentage) {
561
653
  this.action = this.actionableElement.swipe(direction, speed, percentage);
562
- return this.waitForWithAction();
654
+ const traceDescription = actionDescription.swipe(direction, speed, percentage);
655
+ return this.waitForWithAction(traceDescription);
563
656
  }
564
657
 
565
658
  setColumnToValue(column, value) {
566
659
  this.action = this.actionableElement.setColumnToValue(column, value);
567
- return this.waitForWithAction();
660
+ const traceDescription = actionDescription.setColumnToValue(column, value);
661
+ return this.waitForWithAction(traceDescription);
568
662
  }
569
663
 
570
664
  setDatePickerDate(dateString, dateFormat) {
571
665
  this.action = this.actionableElement.setDatePickerDate(dateString, dateFormat);
572
- return this.waitForWithAction();
666
+ const traceDescription = actionDescription.setDatePickerDate(dateString, dateFormat);
667
+ return this.waitForWithAction(traceDescription);
668
+ }
669
+
670
+ performAccessibilityAction(actionName) {
671
+ this.action = this.actionableElement.performAccessibilityAction(actionName);
672
+ const traceDescription = actionDescription.performAccessibilityAction(actionName);
673
+ return this.waitForWithAction(traceDescription);
573
674
  }
574
675
 
575
676
  pinch(scale, speed, angle) {
576
677
  this.action = this.actionableElement.pinch(scale, speed, angle);
577
- return this.waitForWithAction();
678
+ const traceDescription = actionDescription.pinch(scale, speed, angle);
679
+ return this.waitForWithAction(traceDescription);
578
680
  }
579
681
 
580
682
  pinchWithAngle(direction, speed, angle) {
581
683
  this.action = this.actionableElement.pinchWithAngle(direction, speed, angle);
582
- return this.waitForWithAction();
684
+ const traceDescription = actionDescription.pinchWithAngle(direction, speed, angle);
685
+ return this.waitForWithAction(traceDescription);
583
686
  }
584
687
 
585
- waitForWithAction() {
688
+ waitForWithAction(actionTraceDescription) {
586
689
  const expectation = this.expectation;
587
690
  const action = this.action;
588
691
 
589
- return this._invocationManager.execute({
692
+ const invocation = this.createWaitForWithActionInvocation(expectation, action);
693
+
694
+ const traceDescription = expectDescription.waitFor(actionTraceDescription);
695
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
696
+ }
697
+
698
+ createWaitForWithActionInvocation(expectation, action) {
699
+ return {
590
700
  ...action,
591
701
  while: {
592
702
  ...expectation
593
703
  }
594
- });
704
+ };
595
705
  }
596
706
 
597
- waitForWithTimeout() {
707
+ waitForWithTimeout(expectTraceDescription) {
598
708
  const expectation = this.expectation;
599
709
  const action = this.action;
600
710
  const timeout = this.timeout;
601
711
 
602
- return this._invocationManager.execute({
712
+ const invocation = this.createWaitForWithTimeoutInvocation(expectation, action, timeout);
713
+
714
+ const traceDescription = expectDescription.waitForWithTimeout(expectTraceDescription, timeout);
715
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
716
+ }
717
+
718
+ createWaitForWithTimeoutInvocation(expectation, action, timeout) {
719
+ return {
603
720
  ...action,
604
721
  ...expectation,
605
722
  timeout
606
- });
723
+ };
607
724
  }
608
725
  }
609
726
 
@@ -665,4 +782,8 @@ function throwElementError(param) {
665
782
  throw new Error(`${param} is not a Detox element. More about Detox elements here: https://wix.github.io/Detox/docs/api/matchers`);
666
783
  }
667
784
 
785
+ function _executeInvocation(invocationManager, invocation, traceDescription) {
786
+ return traceInvocationCall(traceDescription, invocation, invocationManager.execute(invocation));
787
+ }
788
+
668
789
  module.exports = IosExpect;