detox 19.9.1 → 20.0.2-breaking.new-global-lifecycle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1-javadoc.jar → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1-sources.jar → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1.pom → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-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/detox/src/full/java/com/wix/detox/Detox.java +2 -59
  29. package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
  30. package/index.d.ts +213 -186
  31. package/index.js +1 -0
  32. package/internals.d.ts +131 -0
  33. package/internals.js +4 -0
  34. package/local-cli/build-framework-cache.js +2 -2
  35. package/local-cli/build.js +7 -8
  36. package/local-cli/build.test.js +46 -40
  37. package/local-cli/clean-framework-cache.js +3 -3
  38. package/local-cli/cli.js +0 -1
  39. package/local-cli/init.js +20 -55
  40. package/local-cli/templates/jest.js +9 -34
  41. package/local-cli/test.js +18 -282
  42. package/local-cli/test.test.js +337 -672
  43. package/local-cli/testCommand/TestRunnerCommand.js +156 -0
  44. package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
  45. package/local-cli/testCommand/middlewares.js +75 -0
  46. package/local-cli/{utils → testCommand}/warnings.js +0 -10
  47. package/local-cli/utils/jestInternals.js +13 -2
  48. package/local-cli/utils/yargsUtils.js +67 -0
  49. package/package.json +26 -20
  50. package/runners/deprecation.js +47 -0
  51. package/runners/jest/JestCircusEnvironment.js +3 -38
  52. package/runners/jest/adapter.d.ts +4 -10
  53. package/runners/jest/adapter.js +3 -6
  54. package/runners/jest/assignReporter.d.ts +4 -1
  55. package/runners/jest/assignReporter.js +3 -6
  56. package/runners/jest/deprecation.js +25 -0
  57. package/runners/jest/globalSetup.js +1 -0
  58. package/runners/jest/globalTeardown.js +1 -0
  59. package/runners/jest/index.js +21 -0
  60. package/runners/jest/reporter.js +1 -0
  61. package/runners/jest/reporters/DetoxReporter.js +5 -0
  62. package/runners/jest/specReporter.d.ts +4 -9
  63. package/runners/jest/specReporter.js +3 -10
  64. package/runners/jest/streamlineReporter.js +3 -22
  65. package/runners/jest/testEnvironment/index.js +155 -0
  66. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +36 -22
  67. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
  68. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
  69. package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -7
  70. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -0
  71. package/runners/jest/testEnvironment/listeners/index.js +13 -0
  72. package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
  73. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +56 -0
  74. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -0
  75. package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
  76. package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
  77. package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
  78. package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
  79. package/runners/jest-circus/environment/index.js +6 -0
  80. package/runners/jest-circus/index.js +1 -10
  81. package/runners/jest-circus/reporter.js +1 -0
  82. package/runners/migration.js +37 -0
  83. package/runners/mocha/DetoxMochaAdapter.js +3 -35
  84. package/runners/mocha/adapter.d.ts +4 -7
  85. package/runners/mocha/adapter.js +3 -5
  86. package/src/{Detox.js → DetoxWorker.js} +131 -164
  87. package/src/artifacts/ArtifactsManager.js +51 -2
  88. package/src/artifacts/providers/index.js +0 -4
  89. package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
  90. package/src/artifacts/utils/temporaryPath.js +2 -0
  91. package/src/client/AsyncWebSocket.js +1 -1
  92. package/src/client/actions/actions.js +2 -2
  93. package/src/configuration/collectCliConfig.js +2 -4
  94. package/src/configuration/composeAppsConfig.js +8 -66
  95. package/src/configuration/composeArtifactsConfig.js +6 -32
  96. package/src/configuration/composeBehaviorConfig.js +3 -13
  97. package/src/configuration/composeDeviceConfig.js +37 -62
  98. package/src/configuration/composeLoggerConfig.js +50 -0
  99. package/src/configuration/composeRunnerConfig.js +75 -14
  100. package/src/configuration/composeSessionConfig.js +1 -3
  101. package/src/configuration/index.js +24 -23
  102. package/src/configuration/utils/deviceAppTypes.js +0 -1
  103. package/src/devices/allocation/DeviceAllocator.js +3 -3
  104. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  105. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
  106. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
  107. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
  108. package/src/devices/allocation/factories/index.js +0 -1
  109. package/src/devices/common/drivers/DeviceLauncher.js +2 -2
  110. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
  111. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
  112. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +34 -9
  113. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
  114. package/src/devices/runtime/RuntimeDevice.js +69 -81
  115. package/src/devices/runtime/drivers/index.js +0 -1
  116. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
  117. package/src/devices/runtime/factories/ios.js +1 -8
  118. package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
  119. package/src/devices/runtime/utils/Storage.js +4 -0
  120. package/src/environmentFactory.js +0 -8
  121. package/src/errors/DetoxConfigErrorComposer.js +77 -30
  122. package/src/errors/DetoxError.js +4 -0
  123. package/src/errors/DetoxRuntimeError.js +5 -5
  124. package/src/errors/index.js +2 -0
  125. package/src/ipc/IPCClient.js +118 -0
  126. package/src/ipc/IPCServer.js +94 -0
  127. package/src/ipc/state.js +89 -0
  128. package/src/logger/DetoxLogger.js +244 -0
  129. package/src/logger/DetoxTraceEventBuilder.js +21 -0
  130. package/src/logger/DetoxTracer.js +133 -0
  131. package/src/logger/TraceThreadDispatcher.js +52 -0
  132. package/src/{utils → logger}/customConsoleLogger.js +1 -1
  133. package/src/realms/DetoxConstants.js +13 -0
  134. package/src/realms/DetoxContext.js +170 -0
  135. package/src/realms/DetoxInternalsFacade.js +35 -0
  136. package/src/realms/DetoxPrimaryContext.js +229 -0
  137. package/src/realms/DetoxSecondaryContext.js +94 -0
  138. package/src/realms/index.js +10 -0
  139. package/src/realms/primary.js +3 -0
  140. package/src/realms/secondary.js +3 -0
  141. package/src/server/DetoxConnection.js +1 -1
  142. package/src/symbols.js +56 -0
  143. package/src/utils/Timer.js +14 -6
  144. package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
  145. package/src/utils/logger.js +2 -162
  146. package/src/utils/shellUtils.js +18 -0
  147. package/src/utils/streamUtils.js +214 -0
  148. package/src/utils/trace.js +9 -44
  149. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.md5 +0 -1
  150. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha1 +0 -1
  151. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha256 +0 -1
  152. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha512 +0 -1
  153. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.md5 +0 -1
  154. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha1 +0 -1
  155. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha256 +0 -1
  156. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha512 +0 -1
  157. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar +0 -0
  158. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.md5 +0 -1
  159. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha1 +0 -1
  160. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha256 +0 -1
  161. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha512 +0 -1
  162. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.md5 +0 -1
  163. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha1 +0 -1
  164. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha256 +0 -1
  165. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha512 +0 -1
  166. package/local-cli/templates/mocha.js +0 -32
  167. package/local-cli/utils/splitArgv.js +0 -107
  168. package/runners/integration.js +0 -16
  169. package/runners/jest/DetoxAdapterCircus.js +0 -60
  170. package/runners/jest/DetoxAdapterImpl.js +0 -81
  171. package/runners/jest/DetoxAdapterJasmine.js +0 -67
  172. package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
  173. package/runners/jest/FailingTestsReporter.js +0 -16
  174. package/runners/jest/SpecReporterCircus.js +0 -51
  175. package/runners/jest/SpecReporterJasmine.js +0 -39
  176. package/runners/jest/WorkerAssignReporterCircus.js +0 -17
  177. package/runners/jest/WorkerAssignReporterImpl.js +0 -21
  178. package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
  179. package/runners/jest/runnerInfo.js +0 -9
  180. package/runners/jest-circus/environment.js +0 -206
  181. package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
  182. package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
  183. package/src/DetoxConstants.js +0 -13
  184. package/src/DetoxExportWrapper.js +0 -140
  185. package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -95
  186. package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
  187. package/src/devices/allocation/factories/none.js +0 -11
  188. package/src/index.js +0 -6
  189. package/src/utils/MissingDetox.js +0 -78
  190. package/src/utils/fakeTimestampsProvider.js +0 -9
  191. package/src/utils/getWorkerId.js +0 -5
  192. package/src/utils/lastFailedTests.js +0 -38
  193. 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,50 @@ 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
+ /**
145
+ * Insist on CLI-based retry mechanism even when the failed tests have been handled
146
+ * by jest.retryTimes(n) mechanism from Jest Circus.
147
+ */
148
+ retryAfterCircusRetries?: boolean;
149
+ reportSpecs?: boolean | undefined;
150
+ reportWorkerAssign?: boolean | undefined;
151
+ };
152
+ /**
153
+ * Retries count. Zero means a single attempt to run tests.
154
+ */
155
+ retries?: number;
156
+ /**
157
+ * Custom handler to process --inspect-brk CLI flag.
158
+ * Use it when you rely on another test runner than Jest.
159
+ */
160
+ inspectBrk?: boolean | ((config: DetoxTestRunnerConfig) => void);
161
+ }
162
+
163
+ type DetoxAppConfig = (DetoxBuiltInAppConfig | DetoxCustomAppConfig) & {
119
164
  /**
120
165
  * App name to use with device.selectApp(appName) calls.
121
166
  * Can be omitted if you have a single app under the test.
@@ -127,8 +172,6 @@ declare global {
127
172
 
128
173
  type DetoxDeviceConfig = DetoxBuiltInDeviceConfig | DetoxCustomDriverConfig;
129
174
 
130
- type DetoxConfiguration = DetoxPlainConfiguration | DetoxAliasedConfiguration;
131
-
132
175
  interface DetoxLogArtifactsPluginConfig {
133
176
  enabled?: boolean;
134
177
  keepOnlyFailedTestsArtifacts?: boolean;
@@ -168,9 +211,7 @@ declare global {
168
211
  enabled?: boolean;
169
212
  }
170
213
 
171
- interface DetoxTimelineArtifactsPluginConfig {
172
- enabled?: boolean;
173
- }
214
+ type DetoxBuiltInAppConfig = (DetoxIosAppConfig | DetoxAndroidAppConfig);
174
215
 
175
216
  interface DetoxIosAppConfig {
176
217
  type: 'ios.app';
@@ -189,29 +230,17 @@ declare global {
189
230
  launchArgs?: Record<string, any>;
190
231
  }
191
232
 
192
- interface _DetoxAppConfigFragment {
193
- binaryPath: string;
194
- bundleId?: string;
195
- build?: string;
196
- testBinaryPath?: string;
197
- launchArgs?: Record<string, any>;
233
+ interface DetoxCustomAppConfig {
234
+ type: string;
235
+
236
+ [prop: string]: unknown;
198
237
  }
199
238
 
200
239
  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
- );
240
+ | DetoxIosSimulatorDriverConfig
241
+ | DetoxAttachedAndroidDriverConfig
242
+ | DetoxAndroidEmulatorDriverConfig
243
+ | DetoxGenymotionCloudDriverConfig;
215
244
 
216
245
  interface DetoxIosSimulatorDriverConfig {
217
246
  type: 'ios.simulator';
@@ -219,12 +248,6 @@ declare global {
219
248
  bootArgs?: string;
220
249
  }
221
250
 
222
- interface DetoxIosNoneDriverConfig {
223
- type: 'ios.none';
224
- // TODO: check if we need it at all?
225
- device?: string | Partial<IosSimulatorQuery>;
226
- }
227
-
228
251
  interface DetoxSharedAndroidDriverConfig {
229
252
  forceAdbInstall?: boolean;
230
253
  utilBinaryPaths?: string[];
@@ -239,8 +262,11 @@ declare global {
239
262
  type: 'android.emulator';
240
263
  device: string | { avdName: string };
241
264
  bootArgs?: string;
242
- gpuMode?: 'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest';
265
+ gpuMode?: 'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest' | 'off';
243
266
  headless?: boolean;
267
+ /**
268
+ * @default true
269
+ */
244
270
  readonly?: boolean;
245
271
  }
246
272
 
@@ -264,109 +290,127 @@ declare global {
264
290
 
265
291
  type DetoxKnownDeviceType = DetoxBuiltInDeviceConfig['type'];
266
292
 
267
- type DetoxConfigurationOverrides = {
268
- artifacts?: false | DetoxArtifactsConfig;
269
- behavior?: DetoxBehaviorConfig;
270
- session?: DetoxSessionConfig;
271
- };
293
+ type DetoxConfiguration = DetoxConfigurationCommon & (
294
+ | DetoxConfigurationSingleApp
295
+ | DetoxConfigurationMultiApps
296
+ );
272
297
 
273
- type DetoxAliasedConfiguration =
274
- | DetoxAliasedConfigurationSingleApp
275
- | DetoxAliasedConfigurationMultiApps;
276
-
277
- interface DetoxAliasedConfigurationSingleApp {
278
- type?: never;
298
+ interface DetoxConfigurationSingleApp {
279
299
  device: DetoxAliasedDevice;
280
- app: string | DetoxAppConfig;
300
+ app: DetoxAliasedApp;
281
301
  }
282
302
 
283
- interface DetoxAliasedConfigurationMultiApps {
284
- type?: never;
303
+ interface DetoxConfigurationMultiApps {
285
304
  device: DetoxAliasedDevice;
286
- apps: string[];
305
+ apps: DetoxAliasedApp[];
287
306
  }
288
307
 
289
308
  type DetoxAliasedDevice = string | DetoxDeviceConfig;
290
309
 
310
+ type DetoxAliasedApp = string | DetoxAppConfig;
311
+
291
312
  // endregion DetoxConfig
292
313
 
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
- }
314
+ interface DetoxExportWrapper {
315
+ readonly device: Device;
302
316
 
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>;
317
+ readonly element: ElementFacade;
314
318
 
315
- beforeEach(...args: any[]): Promise<void>;
319
+ readonly waitFor: WaitForFacade;
316
320
 
317
- afterEach(...args: any[]): Promise<void>;
321
+ readonly expect: ExpectFacade;
318
322
 
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>;
323
+ readonly by: ByFacade;
324
+
325
+ readonly web: WebFacade;
326
+
327
+ readonly DetoxConstants: {
328
+ userNotificationTriggers: {
329
+ push: 'push';
330
+ calendar: 'calendar';
331
+ timeInterval: 'timeInterval';
332
+ location: 'location';
333
+ };
334
+ userActivityTypes: {
335
+ searchableItem: string;
336
+ browsingWeb: string;
337
+ },
338
+ searchableItemActivityIdentifier: string;
339
+ };
329
340
 
330
341
  /**
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
342
+ * Detox logger instance. Can be used for saving user logs to the general log file.
334
343
  */
335
- hook(event: 'UNSAFE_configReady', listener: (config: unknown) => void): void;
336
- }
344
+ readonly log: Logger;
337
345
 
338
- interface DetoxInitOptions {
339
346
  /**
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.
347
+ * Detox tracer instance. Can be used for building timelines in Google Event Tracing format.
347
348
  */
348
- initGlobals?: boolean;
349
+ readonly trace: Tracer;
350
+
349
351
  /**
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`.
352
+ * @deprecated
353
353
  */
354
- reuse?: boolean;
354
+ readonly traceCall: _TraceCallSignature;
355
+ }
356
+
357
+ /** @internal */
358
+ type _TraceEventArgs = Record<string, unknown>;
359
+
360
+ type TraceEvent = {
361
+ name?: string;
362
+ cat?: string;
363
+ cname?: string;
364
+ id?: number;
365
+ args?: _TraceEventArgs;
366
+ };
367
+
368
+ /**
369
+ * Trace a duration event before and after executing the action function
370
+ *
371
+ * @internal
372
+ */
373
+ interface _TraceCallSignature {
374
+ <T>(event: string | TraceEvent, action: () => T): T;
375
+ <T>(event: string | TraceEvent, action: () => Promise<T>): Promise<T>;
376
+ }
377
+
378
+ /** @internal */
379
+ interface _TraceSectionSignature<T> {
380
+ (event?: string, args?: _TraceEventArgs): T;
381
+ (event: TraceEvent): T;
355
382
  }
356
383
 
384
+ interface Tracer extends _TraceCallSignature {
385
+ readonly begin: _TraceSectionSignature<EndHandle<{ cname: string; args: _TraceEventArgs; }>>;
386
+ readonly end: _TraceSectionSignature<void>;
387
+
388
+ /** @deprecated */
389
+ readonly startSection: _TraceSectionSignature<void>;
390
+ /** @deprecated */
391
+ readonly endSection: _TraceSectionSignature<void>;
392
+ }
393
+
394
+ type Logger = {
395
+ readonly level: DetoxLogLevel;
396
+
397
+ fatal(context?: unknown, ...args: any[]): void;
398
+ error(context?: unknown, ...args: any[]): void;
399
+ warn(context?: unknown, ...args: any[]): void;
400
+ info(context?: unknown, ...args: any[]): void;
401
+ debug(context?: unknown, ...args: any[]): void;
402
+ trace(context?: unknown, ...args: any[]): void;
403
+
404
+ child(context?: Record<string, unknown>): Logger;
405
+ };
406
+
407
+ type DetoxLogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
408
+
357
409
  type Point2D = {
358
410
  x: number,
359
411
  y: number,
360
412
  }
361
413
 
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
414
  /**
371
415
  * A construct allowing for the querying and modification of user arguments passed to an app upon launch by Detox.
372
416
  *
@@ -414,20 +458,12 @@ declare global {
414
458
  * // }
415
459
  */
416
460
  modify(modifier: object): this;
417
- /**
418
- * @deprecated Use {@link AppLaunchArgs#shared} instead.
419
- */
420
- modify(modifier: object, options: AppLaunchArgsOperationOptions): this;
421
461
 
422
462
  /**
423
463
  * Reset all app-specific launch arguments (back to an empty object).
424
464
  * If you need to reset the shared launch args, use {@link AppLaunchArgs#shared}.
425
465
  */
426
466
  reset(): this;
427
- /**
428
- * @deprecated Use {@link AppLaunchArgs#shared} instead.
429
- */
430
- reset(options: AppLaunchArgsOperationOptions): this;
431
467
 
432
468
  /**
433
469
  * Get all currently set launch arguments (including shared ones).
@@ -435,10 +471,6 @@ declare global {
435
471
  * Note: mutating the values inside the result object is pointless, as it is immutable.
436
472
  */
437
473
  get(): object;
438
- /**
439
- * @deprecated Use {@link AppLaunchArgs#shared} instead.
440
- */
441
- get(options: AppLaunchArgsOperationOptions): object;
442
474
  }
443
475
 
444
476
  /**
@@ -460,12 +492,10 @@ declare global {
460
492
  * 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
493
  * as used by simctl (e.g. AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE).
462
494
  *
463
- * The value will be undefined until the device is properly prepared (i.e. in detox.init())
464
495
  */
465
496
  id: string;
466
497
  /**
467
498
  * 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
499
  */
470
500
  name: string;
471
501
 
@@ -510,6 +540,15 @@ declare global {
510
540
  */
511
541
  launchApp(config?: DeviceLaunchAppConfig): Promise<void>;
512
542
 
543
+ /**
544
+ * Relaunch the app. Convenience method that calls {@link Device#launchApp}
545
+ * with { newInstance: true } override.
546
+ *
547
+ * @param config
548
+ * @see Device#launchApp
549
+ */
550
+ relaunchApp(config?: Omit<DeviceLaunchAppConfig, 'newInstance'>): Promise<void>;
551
+
513
552
  /**
514
553
  * Access the user-defined launch-arguments predefined through static scopes such as the Detox configuration file and
515
554
  * command-line arguments. This access allows - through dedicated methods, for both value-querying and
@@ -535,6 +574,7 @@ declare global {
535
574
  * @see AppLaunchArgs
536
575
  */
537
576
  appLaunchArgs: AppLaunchArgs;
577
+
538
578
  /**
539
579
  * Terminate the app.
540
580
  *
@@ -899,11 +939,13 @@ declare global {
899
939
  * @example await element(by.text('Product').and(by.id('product_name'));
900
940
  */
901
941
  and(by: NativeMatcher): NativeMatcher;
942
+
902
943
  /**
903
944
  * Find an element by a matcher with a parent matcher
904
945
  * @example await element(by.id('Grandson883').withAncestor(by.id('Son883')));
905
946
  */
906
947
  withAncestor(parentBy: NativeMatcher): NativeMatcher;
948
+
907
949
  /**
908
950
  * Find an element by a matcher with a child matcher
909
951
  * @example await element(by.id('Son883').withDescendant(by.id('Grandson883')));
@@ -917,6 +959,7 @@ declare global {
917
959
 
918
960
  interface ExpectFacade {
919
961
  (element: NativeElement): Expect;
962
+
920
963
  (webElement: WebElement): WebExpect;
921
964
  }
922
965
 
@@ -1011,6 +1054,7 @@ declare global {
1011
1054
  * @example await expect(element(by.id('switch'))).toHaveToggleValue(true);
1012
1055
  */
1013
1056
  toHaveToggleValue(value: boolean): R;
1057
+
1014
1058
  /**
1015
1059
  * Expect components like a Switch to have a value ('0' for off, '1' for on).
1016
1060
  * @example await expect(element(by.id('UniqueId533'))).toHaveValue('0');
@@ -1047,6 +1091,7 @@ declare global {
1047
1091
  * @example await waitFor(element(by.text('Text5'))).toBeVisible().whileElement(by.id('ScrollView630')).scroll(50, 'down');
1048
1092
  */
1049
1093
  whileElement(by: NativeMatcher): NativeElement & WaitFor;
1094
+
1050
1095
  // TODO: not sure about & WaitFor - check if we can chain whileElement multiple times
1051
1096
  }
1052
1097
 
@@ -1072,6 +1117,7 @@ declare global {
1072
1117
  */
1073
1118
  longPressAndDrag(duration: number, normalizedPositionX: number, normalizedPositionY: number, targetElement: NativeElement,
1074
1119
  normalizedTargetPositionX: number, normalizedTargetPositionY: number, speed: Speed, holdDuration: number): Promise<void>;
1120
+
1075
1121
  /**
1076
1122
  * Simulate multiple taps on an element.
1077
1123
  * @param times number of times to tap
@@ -1127,10 +1173,10 @@ declare global {
1127
1173
  * @example await element(by.id('scrollView')).scroll(100, 'up');
1128
1174
  */
1129
1175
  scroll(
1130
- pixels: number,
1131
- direction: Direction,
1132
- startPositionX?: number,
1133
- startPositionY?: number,
1176
+ pixels: number,
1177
+ direction: Direction,
1178
+ startPositionX?: number,
1179
+ startPositionY?: number
1134
1180
  ): Promise<void>;
1135
1181
 
1136
1182
  /**
@@ -1138,7 +1184,7 @@ declare global {
1138
1184
  * @example await element(by.id('scrollView')).scrollToIndex(10);
1139
1185
  */
1140
1186
  scrollToIndex(
1141
- index: Number
1187
+ index: Number
1142
1188
  ): Promise<void>;
1143
1189
 
1144
1190
  /**
@@ -1227,7 +1273,7 @@ declare global {
1227
1273
  * // * on failure, to: <artifacts-location>/✗ Menu items should have Logout/tap on menu.png
1228
1274
  * });
1229
1275
  */
1230
- takeScreenshot(name: string): Promise<string>;
1276
+ takeScreenshot(name: string): Promise<string>;
1231
1277
 
1232
1278
  /**
1233
1279
  * Gets the native (OS-dependent) attributes of the element.
@@ -1245,7 +1291,7 @@ declare global {
1245
1291
  * jestExpect(attributes.width).toHaveValue(100);
1246
1292
  * })
1247
1293
  */
1248
- getAttributes(): Promise<IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; }>;
1294
+ getAttributes(): Promise<IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; }>;
1249
1295
  }
1250
1296
 
1251
1297
  interface WebExpect<R = Promise<void>> {
@@ -1261,7 +1307,7 @@ declare global {
1261
1307
  * @example
1262
1308
  * await expect(web.element(by.web.id('UniqueId205'))).toHaveText('ExactText');
1263
1309
  */
1264
- toHaveText(text: string): R
1310
+ toHaveText(text: string): R;
1265
1311
 
1266
1312
  /**
1267
1313
  * Expect the view to exist in the webview DOM tree.
@@ -1282,56 +1328,56 @@ declare global {
1282
1328
  }
1283
1329
 
1284
1330
  interface WebElementActions {
1285
- tap(): Promise<void>
1331
+ tap(): Promise<void>;
1286
1332
 
1287
1333
  /**
1288
1334
  * @param text to type
1289
1335
  * @param isContentEditable whether its a ContentEditable element, default is false.
1290
1336
  */
1291
- typeText(text: string, isContentEditable: boolean): Promise<void>
1337
+ typeText(text: string, isContentEditable: boolean): Promise<void>;
1292
1338
 
1293
1339
  /**
1294
1340
  * At the moment not working on content-editable
1295
1341
  * @param text to replace with the old content.
1296
1342
  */
1297
- replaceText(text: string): Promise<void>
1343
+ replaceText(text: string): Promise<void>;
1298
1344
 
1299
1345
  /**
1300
1346
  * At the moment not working on content-editable
1301
1347
  */
1302
- clearText(): Promise<void>
1348
+ clearText(): Promise<void>;
1303
1349
 
1304
1350
  /**
1305
1351
  * scrolling to the view, the element top position will be at the top of the screen.
1306
1352
  */
1307
- scrollToView(): Promise<void>
1353
+ scrollToView(): Promise<void>;
1308
1354
 
1309
1355
  /**
1310
1356
  * Gets the input content
1311
1357
  */
1312
- getText(): Promise<string>
1358
+ getText(): Promise<string>;
1313
1359
 
1314
1360
  /**
1315
1361
  * Calls the focus function on the element
1316
1362
  */
1317
- focus(): Promise<void>
1363
+ focus(): Promise<void>;
1318
1364
 
1319
1365
  /**
1320
1366
  * Selects all the input content, works on ContentEditable at the moment.
1321
1367
  */
1322
- selectAllText(): Promise<void>
1368
+ selectAllText(): Promise<void>;
1323
1369
 
1324
1370
  /**
1325
1371
  * Moves the input cursor / caret to the end of the content, works on ContentEditable at the moment.
1326
1372
  */
1327
- moveCursorToEnd(): Promise<void>
1373
+ moveCursorToEnd(): Promise<void>;
1328
1374
 
1329
1375
  /**
1330
1376
  * Running a script on the element
1331
1377
  * @param script a method that accept the element as its first arg
1332
1378
  * @example function foo(element) { console.log(element); }
1333
1379
  */
1334
- runScript(script: string): Promise<any>
1380
+ runScript(script: string): Promise<any>;
1335
1381
 
1336
1382
  /**
1337
1383
  * Running a script on the element that accept args
@@ -1445,25 +1491,6 @@ declare global {
1445
1491
  languageAndLocale?: LanguageAndLocale;
1446
1492
  }
1447
1493
 
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
1494
  // Element Attributes Shared Among iOS and Android
1468
1495
  interface ElementAttributes {
1469
1496
  /**