detox 19.9.0 → 21.0.0-breaking.new-global-lifecycle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0-javadoc.jar → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
  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.md5 +1 -0
  3. 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 +1 -0
  4. 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 +1 -0
  5. 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 +1 -0
  6. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0-sources.jar → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar} +0 -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.md5 +1 -0
  8. 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 +1 -0
  9. 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 +1 -0
  10. 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 +1 -0
  11. 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
  12. 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 +1 -0
  13. 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 +1 -0
  14. 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 +1 -0
  15. 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 +1 -0
  16. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0.pom → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom} +2 -2
  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.md5 +1 -0
  18. 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 +1 -0
  19. 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 +1 -0
  20. 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 +1 -0
  21. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  22. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  26. package/Detox-ios-src.tbz +0 -0
  27. package/Detox-ios.tbz +0 -0
  28. package/android/build.gradle +2 -2
  29. package/android/detox/build.gradle +2 -2
  30. package/android/detox/publish-pom.gradle +1 -5
  31. package/android/detox/publishing.gradle +7 -9
  32. package/android/detox/src/full/java/com/wix/detox/Detox.java +2 -59
  33. package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
  34. package/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +1 -3
  35. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +3 -1
  36. package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +1 -1
  37. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +23 -16
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeLoadingMonitor.kt +8 -54
  39. package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +1 -4
  40. package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +1 -2
  41. package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +36 -0
  42. package/android/detox/src/{full → main}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +1 -13
  43. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt +1 -1
  44. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +59 -0
  45. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +3 -15
  46. package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
  47. package/android/gradlew +107 -181
  48. package/index.d.ts +208 -186
  49. package/index.js +1 -0
  50. package/internals.d.ts +124 -0
  51. package/internals.js +4 -0
  52. package/local-cli/build-framework-cache.js +2 -2
  53. package/local-cli/build.js +7 -8
  54. package/local-cli/build.test.js +46 -40
  55. package/local-cli/clean-framework-cache.js +3 -3
  56. package/local-cli/cli.js +0 -1
  57. package/local-cli/init.js +20 -55
  58. package/local-cli/templates/jest.js +9 -34
  59. package/local-cli/test.js +18 -282
  60. package/local-cli/test.test.js +332 -673
  61. package/local-cli/testCommand/TestRunnerCommand.js +157 -0
  62. package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
  63. package/local-cli/testCommand/middlewares.js +75 -0
  64. package/local-cli/{utils → testCommand}/warnings.js +0 -10
  65. package/local-cli/utils/jestInternals.js +13 -2
  66. package/local-cli/utils/yargsUtils.js +67 -0
  67. package/package.json +28 -22
  68. package/runners/deprecation.js +47 -0
  69. package/runners/jest/JestCircusEnvironment.js +3 -38
  70. package/runners/jest/adapter.d.ts +4 -10
  71. package/runners/jest/adapter.js +3 -6
  72. package/runners/jest/assignReporter.d.ts +4 -1
  73. package/runners/jest/assignReporter.js +3 -6
  74. package/runners/jest/deprecation.js +25 -0
  75. package/runners/jest/globalSetup.js +1 -0
  76. package/runners/jest/globalTeardown.js +1 -0
  77. package/runners/jest/index.js +21 -0
  78. package/runners/jest/reporter.js +1 -0
  79. package/runners/jest/reporters/DetoxReporter.js +5 -0
  80. package/runners/jest/specReporter.d.ts +4 -9
  81. package/runners/jest/specReporter.js +3 -10
  82. package/runners/jest/streamlineReporter.js +3 -22
  83. package/runners/jest/testEnvironment/index.js +155 -0
  84. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +35 -17
  85. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
  86. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
  87. package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -7
  88. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -0
  89. package/runners/jest/testEnvironment/listeners/index.js +13 -0
  90. package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
  91. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +56 -0
  92. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -0
  93. package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
  94. package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
  95. package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
  96. package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
  97. package/runners/jest-circus/environment/index.js +6 -0
  98. package/runners/jest-circus/index.js +1 -10
  99. package/runners/jest-circus/reporter.js +1 -0
  100. package/runners/migration.js +37 -0
  101. package/runners/mocha/DetoxMochaAdapter.js +3 -35
  102. package/runners/mocha/adapter.d.ts +4 -7
  103. package/runners/mocha/adapter.js +3 -5
  104. package/src/{Detox.js → DetoxWorker.js} +131 -164
  105. package/src/artifacts/ArtifactsManager.js +51 -2
  106. package/src/artifacts/log/android/ADBLogcatRecording.js +28 -11
  107. package/src/artifacts/providers/index.js +0 -4
  108. package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
  109. package/src/artifacts/utils/temporaryPath.js +2 -0
  110. package/src/client/AsyncWebSocket.js +1 -1
  111. package/src/client/actions/actions.js +2 -2
  112. package/src/configuration/collectCliConfig.js +2 -4
  113. package/src/configuration/composeAppsConfig.js +9 -67
  114. package/src/configuration/composeArtifactsConfig.js +6 -32
  115. package/src/configuration/composeBehaviorConfig.js +3 -13
  116. package/src/configuration/composeDeviceConfig.js +37 -62
  117. package/src/configuration/composeLoggerConfig.js +50 -0
  118. package/src/configuration/composeRunnerConfig.js +74 -14
  119. package/src/configuration/composeSessionConfig.js +1 -3
  120. package/src/configuration/index.js +24 -23
  121. package/src/configuration/utils/deviceAppTypes.js +0 -1
  122. package/src/devices/allocation/DeviceAllocator.js +3 -3
  123. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  124. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
  125. package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +0 -1
  126. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
  127. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
  128. package/src/devices/allocation/factories/index.js +0 -1
  129. package/src/devices/common/drivers/DeviceLauncher.js +2 -2
  130. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
  131. package/src/devices/common/drivers/android/exec/ADB.js +0 -5
  132. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
  133. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +34 -9
  134. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
  135. package/src/devices/runtime/RuntimeDevice.js +69 -81
  136. package/src/devices/runtime/drivers/index.js +0 -1
  137. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
  138. package/src/devices/runtime/factories/ios.js +1 -8
  139. package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
  140. package/src/devices/runtime/utils/Storage.js +4 -0
  141. package/src/environmentFactory.js +0 -8
  142. package/src/errors/DetoxConfigErrorComposer.js +76 -29
  143. package/src/errors/DetoxError.js +4 -0
  144. package/src/errors/DetoxRuntimeError.js +5 -5
  145. package/src/errors/index.js +2 -0
  146. package/src/ipc/IPCClient.js +117 -0
  147. package/src/ipc/IPCServer.js +87 -0
  148. package/src/ipc/state.js +76 -0
  149. package/src/logger/DetoxLogger.js +244 -0
  150. package/src/logger/DetoxTraceEventBuilder.js +21 -0
  151. package/src/logger/DetoxTracer.js +133 -0
  152. package/src/logger/TraceThreadDispatcher.js +52 -0
  153. package/src/{utils → logger}/customConsoleLogger.js +1 -1
  154. package/src/realms/DetoxConstants.js +13 -0
  155. package/src/realms/DetoxContext.js +170 -0
  156. package/src/realms/DetoxInternalsFacade.js +35 -0
  157. package/src/realms/DetoxPrimaryContext.js +229 -0
  158. package/src/realms/DetoxSecondaryContext.js +94 -0
  159. package/src/realms/index.js +10 -0
  160. package/src/realms/primary.js +3 -0
  161. package/src/realms/secondary.js +3 -0
  162. package/src/server/DetoxConnection.js +1 -1
  163. package/src/symbols.js +56 -0
  164. package/src/utils/ChromeTracingExporter.js +5 -6
  165. package/src/utils/Timer.js +14 -6
  166. package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
  167. package/src/utils/logger.js +2 -162
  168. package/src/utils/shellUtils.js +18 -0
  169. package/src/utils/streamUtils.js +214 -0
  170. package/src/utils/trace.js +9 -44
  171. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.md5 +0 -1
  172. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha1 +0 -1
  173. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha256 +0 -1
  174. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha512 +0 -1
  175. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.md5 +0 -1
  176. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha1 +0 -1
  177. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha256 +0 -1
  178. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha512 +0 -1
  179. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar +0 -0
  180. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.md5 +0 -1
  181. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha1 +0 -1
  182. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha256 +0 -1
  183. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha512 +0 -1
  184. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.md5 +0 -1
  185. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha1 +0 -1
  186. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha256 +0 -1
  187. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha512 +0 -1
  188. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -22
  189. package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +0 -75
  190. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +0 -10
  191. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +0 -39
  192. package/local-cli/templates/mocha.js +0 -32
  193. package/local-cli/utils/splitArgv.js +0 -107
  194. package/runners/integration.js +0 -16
  195. package/runners/jest/DetoxAdapterCircus.js +0 -60
  196. package/runners/jest/DetoxAdapterImpl.js +0 -81
  197. package/runners/jest/DetoxAdapterJasmine.js +0 -67
  198. package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
  199. package/runners/jest/FailingTestsReporter.js +0 -16
  200. package/runners/jest/SpecReporterCircus.js +0 -51
  201. package/runners/jest/SpecReporterJasmine.js +0 -39
  202. package/runners/jest/WorkerAssignReporterCircus.js +0 -17
  203. package/runners/jest/WorkerAssignReporterImpl.js +0 -21
  204. package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
  205. package/runners/jest/runnerInfo.js +0 -9
  206. package/runners/jest-circus/environment.js +0 -206
  207. package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
  208. package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
  209. package/src/DetoxConstants.js +0 -13
  210. package/src/DetoxExportWrapper.js +0 -140
  211. package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -95
  212. package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
  213. package/src/devices/allocation/factories/none.js +0 -11
  214. package/src/index.js +0 -6
  215. package/src/utils/MissingDetox.js +0 -78
  216. package/src/utils/fakeTimestampsProvider.js +0 -9
  217. package/src/utils/getWorkerId.js +0 -5
  218. package/src/utils/lastFailedTests.js +0 -38
  219. package/src/utils/sh.js +0 -18
package/index.d.ts CHANGED
@@ -8,6 +8,9 @@
8
8
  // * Max Komarychev <https://github.com/maxkomarychev>
9
9
  // * Dor Ben Baruch <https://github.com/Dor256>
10
10
 
11
+ import { BunyanDebugStreamOptions } from 'bunyan-debug-stream';
12
+ import { EndHandle } from 'trace-event-lib';
13
+
11
14
  declare global {
12
15
  const device: Detox.DetoxExportWrapper['device'];
13
16
  const element: Detox.DetoxExportWrapper['element'];
@@ -15,7 +18,6 @@ declare global {
15
18
  const expect: Detox.DetoxExportWrapper['expect'];
16
19
  const by: Detox.DetoxExportWrapper['by'];
17
20
  const web: Detox.DetoxExportWrapper['web'];
18
- const detoxCircus: Detox.DetoxCircus;
19
21
 
20
22
  namespace NodeJS {
21
23
  interface Global {
@@ -25,49 +27,33 @@ declare global {
25
27
  expect: Detox.DetoxExportWrapper['expect'];
26
28
  by: Detox.DetoxExportWrapper['by'];
27
29
  web: Detox.DetoxExportWrapper['web'];
28
- detoxCircus: Detox.DetoxCircus;
29
30
  }
30
31
  }
31
32
 
32
33
  namespace Detox {
33
34
  // region DetoxConfig
34
35
 
35
- interface DetoxConfig {
36
+ interface DetoxConfig extends DetoxConfigurationCommon {
36
37
  /**
37
38
  * @example extends: './relative/detox.config'
38
39
  * @example extends: '@my-org/detox-preset'
39
40
  */
40
41
  extends?: string;
41
- /**
42
- * @example testRunner: 'jest'
43
- * @example testRunner: 'mocha'
44
- */
45
- testRunner?: string;
46
- /**
47
- * Stops passing default `--maxWorkers 1` to the test runner,
48
- * presuming that from now on you have that already configured
49
- * in your test runner config as a default.
50
- */
51
- skipLegacyWorkersInjection?: boolean;
52
- /**
53
- * @example runnerConfig: 'e2e/config.js'
54
- */
55
- runnerConfig?: string;
56
- /**
57
- * Optional. A default glob pattern for a test runner to use when no test files are specified.
58
- *
59
- * @example specs: 'detoxE2E'
60
- */
61
- specs?: string;
62
- artifacts?: DetoxArtifactsConfig;
63
- behavior?: DetoxBehaviorConfig;
64
- session?: DetoxSessionConfig;
42
+
65
43
  apps?: Record<string, DetoxAppConfig>;
66
44
  devices?: Record<string, DetoxDeviceConfig>;
67
45
  selectedConfiguration?: string;
68
46
  configurations: Record<string, DetoxConfiguration>;
69
47
  }
70
48
 
49
+ type DetoxConfigurationCommon = {
50
+ artifacts?: false | DetoxArtifactsConfig;
51
+ behavior?: DetoxBehaviorConfig;
52
+ logger?: DetoxLoggerConfig;
53
+ session?: DetoxSessionConfig;
54
+ testRunner?: DetoxTestRunnerConfig;
55
+ };
56
+
71
57
  interface DetoxArtifactsConfig {
72
58
  rootDir?: string;
73
59
  pathBuilder?: string;
@@ -76,7 +62,6 @@ declare global {
76
62
  screenshot?: 'none' | 'manual' | 'failing' | 'all' | DetoxScreenshotArtifactsPluginConfig;
77
63
  video?: 'none' | 'failing' | 'all' | DetoxVideoArtifactsPluginConfig;
78
64
  instruments?: 'none' | 'all' | DetoxInstrumentsArtifactsPluginConfig;
79
- timeline?: 'none' | 'all' | DetoxTimelineArtifactsPluginConfig;
80
65
  uiHierarchy?: 'disabled' | 'enabled' | DetoxUIHierarchyArtifactsPluginConfig;
81
66
 
82
67
  [pluginId: string]: unknown;
@@ -96,11 +81,19 @@ declare global {
96
81
  */
97
82
  exposeGlobals?: boolean;
98
83
  /**
99
- * By default, `await detox.init()` will uninstall and install the app.
84
+ * By default, Detox will uninstall and install the app upon the initialization.
100
85
  * If you wish to reuse the existing app for a faster run, set the property to
101
86
  * `false`.
102
87
  */
103
88
  reinstallApp?: boolean;
89
+ /**
90
+ * If you wish to run multiple "detox test" commands in parallel,
91
+ * make sure they don't delete the shared lock file – only the
92
+ * first command should reset the lock file.
93
+ *
94
+ * @default false
95
+ */
96
+ keepLockFile?: boolean;
104
97
  };
105
98
  launchApp?: 'auto' | 'manual';
106
99
  cleanup?: {
@@ -108,6 +101,15 @@ declare global {
108
101
  };
109
102
  }
110
103
 
104
+ interface DetoxLoggerConfig {
105
+ level?: DetoxLogLevel;
106
+ /**
107
+ * @default 'sandbox'
108
+ */
109
+ overrideConsole?: 'all' | 'sandbox' | 'none';
110
+ options?: BunyanDebugStreamOptions;
111
+ }
112
+
111
113
  interface DetoxSessionConfig {
112
114
  autoStart?: boolean;
113
115
  debugSynchronization?: number;
@@ -115,7 +117,45 @@ declare global {
115
117
  sessionId?: string;
116
118
  }
117
119
 
118
- type DetoxAppConfig = (DetoxIosAppConfig | DetoxAndroidAppConfig) & {
120
+ interface DetoxTestRunnerConfig {
121
+ args?: {
122
+ /**
123
+ * The command to use for runner: 'jest', 'nyc jest',
124
+ */
125
+ $0: string;
126
+ /**
127
+ * The positional arguments to pass to the runner.
128
+ */
129
+ _?: string[];
130
+ /**
131
+ * Any other properties recognized by test runner
132
+ */
133
+ [prop: string]: unknown;
134
+ };
135
+ /**
136
+ * Configuration of custom integration features
137
+ * between Detox and Jest
138
+ */
139
+ jest?: {
140
+ /**
141
+ * Device init timeout
142
+ */
143
+ initTimeout?: number | undefined;
144
+ reportSpecs?: boolean | undefined;
145
+ reportWorkerAssign?: boolean | undefined;
146
+ };
147
+ /**
148
+ * Retries count. Zero means a single attempt to run tests.
149
+ */
150
+ retries?: number;
151
+ /**
152
+ * Custom handler to process --inspect-brk CLI flag.
153
+ * Use it when you rely on another test runner than Jest.
154
+ */
155
+ inspectBrk?: boolean | ((config: DetoxTestRunnerConfig) => void);
156
+ }
157
+
158
+ type DetoxAppConfig = (DetoxBuiltInAppConfig | DetoxCustomAppConfig) & {
119
159
  /**
120
160
  * App name to use with device.selectApp(appName) calls.
121
161
  * Can be omitted if you have a single app under the test.
@@ -127,8 +167,6 @@ declare global {
127
167
 
128
168
  type DetoxDeviceConfig = DetoxBuiltInDeviceConfig | DetoxCustomDriverConfig;
129
169
 
130
- type DetoxConfiguration = DetoxPlainConfiguration | DetoxAliasedConfiguration;
131
-
132
170
  interface DetoxLogArtifactsPluginConfig {
133
171
  enabled?: boolean;
134
172
  keepOnlyFailedTestsArtifacts?: boolean;
@@ -168,9 +206,7 @@ declare global {
168
206
  enabled?: boolean;
169
207
  }
170
208
 
171
- interface DetoxTimelineArtifactsPluginConfig {
172
- enabled?: boolean;
173
- }
209
+ type DetoxBuiltInAppConfig = (DetoxIosAppConfig | DetoxAndroidAppConfig);
174
210
 
175
211
  interface DetoxIosAppConfig {
176
212
  type: 'ios.app';
@@ -189,29 +225,17 @@ declare global {
189
225
  launchArgs?: Record<string, any>;
190
226
  }
191
227
 
192
- interface _DetoxAppConfigFragment {
193
- binaryPath: string;
194
- bundleId?: string;
195
- build?: string;
196
- testBinaryPath?: string;
197
- launchArgs?: Record<string, any>;
228
+ interface DetoxCustomAppConfig {
229
+ type: string;
230
+
231
+ [prop: string]: unknown;
198
232
  }
199
233
 
200
234
  type DetoxBuiltInDeviceConfig =
201
- | DetoxIosSimulatorDriverConfig
202
- | DetoxIosNoneDriverConfig
203
- | DetoxAttachedAndroidDriverConfig
204
- | DetoxAndroidEmulatorDriverConfig
205
- | DetoxGenymotionCloudDriverConfig;
206
-
207
- type DetoxPlainConfiguration = DetoxConfigurationOverrides & (
208
- | (DetoxIosSimulatorDriverConfig & _DetoxAppConfigFragment)
209
- | (DetoxIosNoneDriverConfig & _DetoxAppConfigFragment)
210
- | (DetoxAttachedAndroidDriverConfig & _DetoxAppConfigFragment)
211
- | (DetoxAndroidEmulatorDriverConfig & _DetoxAppConfigFragment)
212
- | (DetoxGenymotionCloudDriverConfig & _DetoxAppConfigFragment)
213
- | (DetoxCustomDriverConfig)
214
- );
235
+ | DetoxIosSimulatorDriverConfig
236
+ | DetoxAttachedAndroidDriverConfig
237
+ | DetoxAndroidEmulatorDriverConfig
238
+ | DetoxGenymotionCloudDriverConfig;
215
239
 
216
240
  interface DetoxIosSimulatorDriverConfig {
217
241
  type: 'ios.simulator';
@@ -219,12 +243,6 @@ declare global {
219
243
  bootArgs?: string;
220
244
  }
221
245
 
222
- interface DetoxIosNoneDriverConfig {
223
- type: 'ios.none';
224
- // TODO: check if we need it at all?
225
- device?: string | Partial<IosSimulatorQuery>;
226
- }
227
-
228
246
  interface DetoxSharedAndroidDriverConfig {
229
247
  forceAdbInstall?: boolean;
230
248
  utilBinaryPaths?: string[];
@@ -239,8 +257,11 @@ declare global {
239
257
  type: 'android.emulator';
240
258
  device: string | { avdName: string };
241
259
  bootArgs?: string;
242
- gpuMode?: 'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest';
260
+ gpuMode?: 'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest' | 'off';
243
261
  headless?: boolean;
262
+ /**
263
+ * @default true
264
+ */
244
265
  readonly?: boolean;
245
266
  }
246
267
 
@@ -264,109 +285,127 @@ declare global {
264
285
 
265
286
  type DetoxKnownDeviceType = DetoxBuiltInDeviceConfig['type'];
266
287
 
267
- type DetoxConfigurationOverrides = {
268
- artifacts?: false | DetoxArtifactsConfig;
269
- behavior?: DetoxBehaviorConfig;
270
- session?: DetoxSessionConfig;
271
- };
272
-
273
- type DetoxAliasedConfiguration =
274
- | DetoxAliasedConfigurationSingleApp
275
- | DetoxAliasedConfigurationMultiApps;
288
+ type DetoxConfiguration = DetoxConfigurationCommon & (
289
+ | DetoxConfigurationSingleApp
290
+ | DetoxConfigurationMultiApps
291
+ );
276
292
 
277
- interface DetoxAliasedConfigurationSingleApp {
278
- type?: never;
293
+ interface DetoxConfigurationSingleApp {
279
294
  device: DetoxAliasedDevice;
280
- app: string | DetoxAppConfig;
295
+ app: DetoxAliasedApp;
281
296
  }
282
297
 
283
- interface DetoxAliasedConfigurationMultiApps {
284
- type?: never;
298
+ interface DetoxConfigurationMultiApps {
285
299
  device: DetoxAliasedDevice;
286
- apps: string[];
300
+ apps: DetoxAliasedApp[];
287
301
  }
288
302
 
289
303
  type DetoxAliasedDevice = string | DetoxDeviceConfig;
290
304
 
305
+ type DetoxAliasedApp = string | DetoxAppConfig;
306
+
291
307
  // endregion DetoxConfig
292
308
 
293
- // Detox exports all methods from detox global and all of the global constants.
294
- interface DetoxInstance {
295
- device: Device;
296
- element: ElementFacade;
297
- waitFor: WaitForFacade;
298
- expect: ExpectFacade;
299
- by: ByFacade;
300
- web: WebFacade;
301
- }
309
+ interface DetoxExportWrapper {
310
+ readonly device: Device;
302
311
 
303
- interface DetoxExportWrapper extends DetoxInstance {
304
- /**
305
- * The setup phase happens inside detox.init(). This is the phase where detox reads its configuration, starts a server, loads its expection library and starts a simulator
306
- *
307
- * @param configOverride - this object is deep-merged with the selected Detox configuration from .detoxrc
308
- * @example
309
- * beforeAll(async () => {
310
- * await detox.init();
311
- * });
312
- */
313
- init(configOverride?: Partial<DetoxConfig>, options?: DetoxInitOptions): Promise<void>;
312
+ readonly element: ElementFacade;
314
313
 
315
- beforeEach(...args: any[]): Promise<void>;
314
+ readonly waitFor: WaitForFacade;
316
315
 
317
- afterEach(...args: any[]): Promise<void>;
316
+ readonly expect: ExpectFacade;
318
317
 
319
- /**
320
- * The cleanup phase should happen after all the tests have finished.
321
- * This is the phase where the Detox server shuts down.
322
- *
323
- * @example
324
- * after(async () => {
325
- * await detox.cleanup();
326
- * });
327
- */
328
- cleanup(): Promise<void>;
318
+ readonly by: ByFacade;
319
+
320
+ readonly web: WebFacade;
321
+
322
+ readonly DetoxConstants: {
323
+ userNotificationTriggers: {
324
+ push: 'push';
325
+ calendar: 'calendar';
326
+ timeInterval: 'timeInterval';
327
+ location: 'location';
328
+ };
329
+ userActivityTypes: {
330
+ searchableItem: string;
331
+ browsingWeb: string;
332
+ },
333
+ searchableItemActivityIdentifier: string;
334
+ };
329
335
 
330
336
  /**
331
- * Unstable. API to access an assembled detox config before it gets passed to testRunner
332
- * or detox.init(). Use it only if you don't have another option.
333
- * @internal
337
+ * Detox logger instance. Can be used for saving user logs to the general log file.
334
338
  */
335
- hook(event: 'UNSAFE_configReady', listener: (config: unknown) => void): void;
336
- }
339
+ readonly log: Logger;
337
340
 
338
- interface DetoxInitOptions {
339
341
  /**
340
- * By default, Detox exports `device`, `expect`, `element`, `by` and `waitFor`
341
- * as global variables. If you want to control their initialization manually,
342
- * set this property to `false`.
343
- *
344
- * This is useful when during E2E tests you also need to run regular expectations
345
- * in Node.js. Jest's `expect` for instance, will not be overridden by Detox when
346
- * this option is used.
342
+ * Detox tracer instance. Can be used for building timelines in Google Event Tracing format.
347
343
  */
348
- initGlobals?: boolean;
344
+ readonly trace: Tracer;
345
+
349
346
  /**
350
- * By default, `await detox.init()` will uninstall and install the app.
351
- * If you wish to reuse the existing app for a faster run, set the property to
352
- * `false`.
347
+ * @deprecated
353
348
  */
354
- reuse?: boolean;
349
+ readonly traceCall: _TraceCallSignature;
350
+ }
351
+
352
+ /** @internal */
353
+ type _TraceEventArgs = Record<string, unknown>;
354
+
355
+ type TraceEvent = {
356
+ name?: string;
357
+ cat?: string;
358
+ cname?: string;
359
+ id?: number;
360
+ args?: _TraceEventArgs;
361
+ };
362
+
363
+ /**
364
+ * Trace a duration event before and after executing the action function
365
+ *
366
+ * @internal
367
+ */
368
+ interface _TraceCallSignature {
369
+ <T>(event: string | TraceEvent, action: () => T): T;
370
+ <T>(event: string | TraceEvent, action: () => Promise<T>): Promise<T>;
371
+ }
372
+
373
+ /** @internal */
374
+ interface _TraceSectionSignature<T> {
375
+ (event?: string, args?: _TraceEventArgs): T;
376
+ (event: TraceEvent): T;
355
377
  }
356
378
 
379
+ interface Tracer extends _TraceCallSignature {
380
+ readonly begin: _TraceSectionSignature<EndHandle<{ cname: string; args: _TraceEventArgs; }>>;
381
+ readonly end: _TraceSectionSignature<void>;
382
+
383
+ /** @deprecated */
384
+ readonly startSection: _TraceSectionSignature<void>;
385
+ /** @deprecated */
386
+ readonly endSection: _TraceSectionSignature<void>;
387
+ }
388
+
389
+ type Logger = {
390
+ readonly level: DetoxLogLevel;
391
+
392
+ fatal(context?: unknown, ...args: any[]): void;
393
+ error(context?: unknown, ...args: any[]): void;
394
+ warn(context?: unknown, ...args: any[]): void;
395
+ info(context?: unknown, ...args: any[]): void;
396
+ debug(context?: unknown, ...args: any[]): void;
397
+ trace(context?: unknown, ...args: any[]): void;
398
+
399
+ child(context?: Record<string, unknown>): Logger;
400
+ };
401
+
402
+ type DetoxLogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
403
+
357
404
  type Point2D = {
358
405
  x: number,
359
406
  y: number,
360
407
  }
361
408
 
362
- /**
363
- * @deprecated
364
- */
365
- type AppLaunchArgsOperationOptions = Partial<{
366
- /** Changes the scope of the operation: transient or permanent app launch args */
367
- permanent: boolean;
368
- }>;
369
-
370
409
  /**
371
410
  * A construct allowing for the querying and modification of user arguments passed to an app upon launch by Detox.
372
411
  *
@@ -414,20 +453,12 @@ declare global {
414
453
  * // }
415
454
  */
416
455
  modify(modifier: object): this;
417
- /**
418
- * @deprecated Use {@link AppLaunchArgs#shared} instead.
419
- */
420
- modify(modifier: object, options: AppLaunchArgsOperationOptions): this;
421
456
 
422
457
  /**
423
458
  * Reset all app-specific launch arguments (back to an empty object).
424
459
  * If you need to reset the shared launch args, use {@link AppLaunchArgs#shared}.
425
460
  */
426
461
  reset(): this;
427
- /**
428
- * @deprecated Use {@link AppLaunchArgs#shared} instead.
429
- */
430
- reset(options: AppLaunchArgsOperationOptions): this;
431
462
 
432
463
  /**
433
464
  * Get all currently set launch arguments (including shared ones).
@@ -435,10 +466,6 @@ declare global {
435
466
  * Note: mutating the values inside the result object is pointless, as it is immutable.
436
467
  */
437
468
  get(): object;
438
- /**
439
- * @deprecated Use {@link AppLaunchArgs#shared} instead.
440
- */
441
- get(options: AppLaunchArgsOperationOptions): object;
442
469
  }
443
470
 
444
471
  /**
@@ -460,12 +487,10 @@ declare global {
460
487
  * Holds the environment-unique ID of the device - namely, the adb ID on Android (e.g. emulator-5554) and the Mac-global simulator UDID on iOS,
461
488
  * as used by simctl (e.g. AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE).
462
489
  *
463
- * The value will be undefined until the device is properly prepared (i.e. in detox.init())
464
490
  */
465
491
  id: string;
466
492
  /**
467
493
  * Holds a descriptive name of the device. Example: emulator-5554 (Pixel_API_29)
468
- * The value will be undefined until the device is properly prepared (i.e. in detox.init()).
469
494
  */
470
495
  name: string;
471
496
 
@@ -510,6 +535,15 @@ declare global {
510
535
  */
511
536
  launchApp(config?: DeviceLaunchAppConfig): Promise<void>;
512
537
 
538
+ /**
539
+ * Relaunch the app. Convenience method that calls {@link Device#launchApp}
540
+ * with { newInstance: true } override.
541
+ *
542
+ * @param config
543
+ * @see Device#launchApp
544
+ */
545
+ relaunchApp(config?: Omit<DeviceLaunchAppConfig, 'newInstance'>): Promise<void>;
546
+
513
547
  /**
514
548
  * Access the user-defined launch-arguments predefined through static scopes such as the Detox configuration file and
515
549
  * command-line arguments. This access allows - through dedicated methods, for both value-querying and
@@ -535,6 +569,7 @@ declare global {
535
569
  * @see AppLaunchArgs
536
570
  */
537
571
  appLaunchArgs: AppLaunchArgs;
572
+
538
573
  /**
539
574
  * Terminate the app.
540
575
  *
@@ -899,11 +934,13 @@ declare global {
899
934
  * @example await element(by.text('Product').and(by.id('product_name'));
900
935
  */
901
936
  and(by: NativeMatcher): NativeMatcher;
937
+
902
938
  /**
903
939
  * Find an element by a matcher with a parent matcher
904
940
  * @example await element(by.id('Grandson883').withAncestor(by.id('Son883')));
905
941
  */
906
942
  withAncestor(parentBy: NativeMatcher): NativeMatcher;
943
+
907
944
  /**
908
945
  * Find an element by a matcher with a child matcher
909
946
  * @example await element(by.id('Son883').withDescendant(by.id('Grandson883')));
@@ -917,6 +954,7 @@ declare global {
917
954
 
918
955
  interface ExpectFacade {
919
956
  (element: NativeElement): Expect;
957
+
920
958
  (webElement: WebElement): WebExpect;
921
959
  }
922
960
 
@@ -1011,6 +1049,7 @@ declare global {
1011
1049
  * @example await expect(element(by.id('switch'))).toHaveToggleValue(true);
1012
1050
  */
1013
1051
  toHaveToggleValue(value: boolean): R;
1052
+
1014
1053
  /**
1015
1054
  * Expect components like a Switch to have a value ('0' for off, '1' for on).
1016
1055
  * @example await expect(element(by.id('UniqueId533'))).toHaveValue('0');
@@ -1047,6 +1086,7 @@ declare global {
1047
1086
  * @example await waitFor(element(by.text('Text5'))).toBeVisible().whileElement(by.id('ScrollView630')).scroll(50, 'down');
1048
1087
  */
1049
1088
  whileElement(by: NativeMatcher): NativeElement & WaitFor;
1089
+
1050
1090
  // TODO: not sure about & WaitFor - check if we can chain whileElement multiple times
1051
1091
  }
1052
1092
 
@@ -1072,6 +1112,7 @@ declare global {
1072
1112
  */
1073
1113
  longPressAndDrag(duration: number, normalizedPositionX: number, normalizedPositionY: number, targetElement: NativeElement,
1074
1114
  normalizedTargetPositionX: number, normalizedTargetPositionY: number, speed: Speed, holdDuration: number): Promise<void>;
1115
+
1075
1116
  /**
1076
1117
  * Simulate multiple taps on an element.
1077
1118
  * @param times number of times to tap
@@ -1127,10 +1168,10 @@ declare global {
1127
1168
  * @example await element(by.id('scrollView')).scroll(100, 'up');
1128
1169
  */
1129
1170
  scroll(
1130
- pixels: number,
1131
- direction: Direction,
1132
- startPositionX?: number,
1133
- startPositionY?: number,
1171
+ pixels: number,
1172
+ direction: Direction,
1173
+ startPositionX?: number,
1174
+ startPositionY?: number
1134
1175
  ): Promise<void>;
1135
1176
 
1136
1177
  /**
@@ -1138,7 +1179,7 @@ declare global {
1138
1179
  * @example await element(by.id('scrollView')).scrollToIndex(10);
1139
1180
  */
1140
1181
  scrollToIndex(
1141
- index: Number
1182
+ index: Number
1142
1183
  ): Promise<void>;
1143
1184
 
1144
1185
  /**
@@ -1227,7 +1268,7 @@ declare global {
1227
1268
  * // * on failure, to: <artifacts-location>/✗ Menu items should have Logout/tap on menu.png
1228
1269
  * });
1229
1270
  */
1230
- takeScreenshot(name: string): Promise<string>;
1271
+ takeScreenshot(name: string): Promise<string>;
1231
1272
 
1232
1273
  /**
1233
1274
  * Gets the native (OS-dependent) attributes of the element.
@@ -1245,7 +1286,7 @@ declare global {
1245
1286
  * jestExpect(attributes.width).toHaveValue(100);
1246
1287
  * })
1247
1288
  */
1248
- getAttributes(): Promise<IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; }>;
1289
+ getAttributes(): Promise<IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; }>;
1249
1290
  }
1250
1291
 
1251
1292
  interface WebExpect<R = Promise<void>> {
@@ -1261,7 +1302,7 @@ declare global {
1261
1302
  * @example
1262
1303
  * await expect(web.element(by.web.id('UniqueId205'))).toHaveText('ExactText');
1263
1304
  */
1264
- toHaveText(text: string): R
1305
+ toHaveText(text: string): R;
1265
1306
 
1266
1307
  /**
1267
1308
  * Expect the view to exist in the webview DOM tree.
@@ -1282,56 +1323,56 @@ declare global {
1282
1323
  }
1283
1324
 
1284
1325
  interface WebElementActions {
1285
- tap(): Promise<void>
1326
+ tap(): Promise<void>;
1286
1327
 
1287
1328
  /**
1288
1329
  * @param text to type
1289
1330
  * @param isContentEditable whether its a ContentEditable element, default is false.
1290
1331
  */
1291
- typeText(text: string, isContentEditable: boolean): Promise<void>
1332
+ typeText(text: string, isContentEditable: boolean): Promise<void>;
1292
1333
 
1293
1334
  /**
1294
1335
  * At the moment not working on content-editable
1295
1336
  * @param text to replace with the old content.
1296
1337
  */
1297
- replaceText(text: string): Promise<void>
1338
+ replaceText(text: string): Promise<void>;
1298
1339
 
1299
1340
  /**
1300
1341
  * At the moment not working on content-editable
1301
1342
  */
1302
- clearText(): Promise<void>
1343
+ clearText(): Promise<void>;
1303
1344
 
1304
1345
  /**
1305
1346
  * scrolling to the view, the element top position will be at the top of the screen.
1306
1347
  */
1307
- scrollToView(): Promise<void>
1348
+ scrollToView(): Promise<void>;
1308
1349
 
1309
1350
  /**
1310
1351
  * Gets the input content
1311
1352
  */
1312
- getText(): Promise<string>
1353
+ getText(): Promise<string>;
1313
1354
 
1314
1355
  /**
1315
1356
  * Calls the focus function on the element
1316
1357
  */
1317
- focus(): Promise<void>
1358
+ focus(): Promise<void>;
1318
1359
 
1319
1360
  /**
1320
1361
  * Selects all the input content, works on ContentEditable at the moment.
1321
1362
  */
1322
- selectAllText(): Promise<void>
1363
+ selectAllText(): Promise<void>;
1323
1364
 
1324
1365
  /**
1325
1366
  * Moves the input cursor / caret to the end of the content, works on ContentEditable at the moment.
1326
1367
  */
1327
- moveCursorToEnd(): Promise<void>
1368
+ moveCursorToEnd(): Promise<void>;
1328
1369
 
1329
1370
  /**
1330
1371
  * Running a script on the element
1331
1372
  * @param script a method that accept the element as its first arg
1332
1373
  * @example function foo(element) { console.log(element); }
1333
1374
  */
1334
- runScript(script: string): Promise<any>
1375
+ runScript(script: string): Promise<any>;
1335
1376
 
1336
1377
  /**
1337
1378
  * Running a script on the element that accept args
@@ -1445,25 +1486,6 @@ declare global {
1445
1486
  languageAndLocale?: LanguageAndLocale;
1446
1487
  }
1447
1488
 
1448
- interface CircusTestEventListenerBase {
1449
- handleTestEvent(event: any, state: any): Promise<void>;
1450
- }
1451
-
1452
- interface DetoxCircus {
1453
- /**
1454
- * A get function that Enables access to this instance (single in each worker's scope)
1455
- */
1456
- getEnv(): {
1457
- /**
1458
- * Registers a listener such as an adapter or reporter
1459
- * @example
1460
- * detoxCircus.getEnv().addEventsListener(adapter)
1461
- * detoxCircus.getEnv().addEventsListener(assignReporter)
1462
- */
1463
- addEventsListener(listener: CircusTestEventListenerBase): void
1464
- };
1465
- }
1466
-
1467
1489
  // Element Attributes Shared Among iOS and Android
1468
1490
  interface ElementAttributes {
1469
1491
  /**