detox 20.0.1-breaking.new-global-lifecycle.0 → 20.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. package/Detox-android/com/wix/detox/{20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.1/detox-20.0.1-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar → 20.0.1/detox-20.0.1-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom → 20.0.1/detox-20.0.1.pom} +1 -7
  17. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.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/README.md +1 -1
  29. package/android/build.gradle +12 -7
  30. package/android/detox/build.gradle +13 -9
  31. package/android/detox/proguard-rules-app.pro +6 -0
  32. package/android/detox/proguard-rules.pro +3 -0
  33. package/android/detox/publishing.gradle +27 -27
  34. package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
  35. package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
  36. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +1 -1
  37. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
  39. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +19 -13
  40. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +33 -30
  41. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
  42. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
  43. package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
  44. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
  45. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
  46. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
  47. package/index.d.ts +198 -57
  48. package/internals.d.ts +219 -45
  49. package/local-cli/build.js +2 -2
  50. package/local-cli/build.test.js +14 -14
  51. package/local-cli/cli.js +8 -6
  52. package/local-cli/init.js +61 -21
  53. package/local-cli/rebuild-framework-cache.js +1 -1
  54. package/local-cli/reset-lock-file.js +16 -0
  55. package/local-cli/templates/jest.js +13 -10
  56. package/local-cli/test.js +14 -8
  57. package/local-cli/test.test.js +148 -61
  58. package/local-cli/testCommand/TestRunnerCommand.js +78 -72
  59. package/local-cli/testCommand/builder.js +0 -1
  60. package/local-cli/testCommand/middlewares.js +4 -13
  61. package/local-cli/testCommand/warnings.js +0 -3
  62. package/local-cli/utils/jestInternals.js +4 -1
  63. package/package.json +23 -16
  64. package/runners/deprecation.js +42 -44
  65. package/runners/jest/globalSetup.js +1 -1
  66. package/runners/jest/globalTeardown.js +1 -1
  67. package/runners/jest/index.d.ts +60 -0
  68. package/runners/jest/index.js +3 -8
  69. package/runners/jest/index.test.js +13 -0
  70. package/runners/jest/reporters/DetoxReporter.js +33 -2
  71. package/runners/jest/testEnvironment/index.js +119 -69
  72. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +94 -51
  73. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
  74. package/runners/jest/testEnvironment/listeners/SpecReporter.js +14 -16
  75. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +2 -6
  76. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  77. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
  78. package/src/DetoxWorker.js +105 -62
  79. package/src/android/core/NativeElement.js +56 -20
  80. package/src/android/core/NativeExpect.js +28 -9
  81. package/src/android/interactions/native.js +25 -18
  82. package/src/artifacts/ArtifactsManager.js +14 -47
  83. package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
  84. package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
  85. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
  86. package/src/artifacts/templates/artifact/Artifact.js +1 -1
  87. package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
  88. package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
  89. package/src/artifacts/utils/temporaryPath.js +18 -7
  90. package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
  91. package/src/client/AsyncWebSocket.js +8 -17
  92. package/src/client/Client.js +19 -2
  93. package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
  94. package/src/configuration/collectCliConfig.js +1 -12
  95. package/src/configuration/composeAppsConfig.js +4 -0
  96. package/src/configuration/composeDeviceConfig.js +1 -1
  97. package/src/configuration/composeLoggerConfig.js +19 -10
  98. package/src/configuration/composeRunnerConfig.js +62 -9
  99. package/src/configuration/index.js +14 -9
  100. package/src/configuration/loadExternalConfig.js +1 -1
  101. package/src/devices/allocation/DeviceAllocator.js +3 -2
  102. package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
  103. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  104. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
  105. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -2
  106. package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
  107. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
  108. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
  109. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
  110. package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  111. package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
  112. package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
  113. package/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js +1 -1
  114. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +29 -3
  115. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
  116. package/src/devices/runtime/RuntimeDevice.js +19 -12
  117. package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
  118. package/src/devices/runtime/drivers/android/AndroidDriver.js +10 -2
  119. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
  120. package/src/errors/DetoxConfigErrorComposer.js +17 -2
  121. package/src/ios/expectTwo.js +153 -67
  122. package/src/ipc/IPCClient.js +12 -12
  123. package/src/ipc/IPCServer.js +29 -18
  124. package/src/ipc/{state.js → SessionState.js} +26 -40
  125. package/src/logger/DetoxLogger.js +261 -157
  126. package/src/logger/index.js +5 -0
  127. package/src/logger/utils/BunyanLogger.js +76 -0
  128. package/src/logger/utils/CategoryThreadDispatcher.js +36 -0
  129. package/src/logger/utils/DetoxLogFinalizer.js +140 -0
  130. package/src/logger/utils/MessageStack.js +24 -0
  131. package/src/logger/utils/ThreadDispatcher.js +61 -0
  132. package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +5 -4
  133. package/src/logger/utils/sanitizeBunyanContext.js +30 -0
  134. package/src/{utils → logger/utils}/streamUtils.js +51 -17
  135. package/src/logger/utils/tracerLegacy.js +37 -0
  136. package/src/realms/DetoxContext.js +78 -65
  137. package/src/realms/DetoxInternalsFacade.js +8 -12
  138. package/src/realms/DetoxPrimaryContext.js +104 -72
  139. package/src/realms/DetoxSecondaryContext.js +29 -32
  140. package/src/server/DetoxConnection.js +18 -23
  141. package/src/server/DetoxServer.js +7 -10
  142. package/src/server/DetoxSession.js +6 -6
  143. package/src/server/DetoxSessionManager.js +1 -1
  144. package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
  145. package/src/symbols.js +16 -22
  146. package/src/utils/Timer.js +55 -38
  147. package/src/utils/argparse.js +11 -0
  148. package/src/utils/childProcess/exec.js +1 -1
  149. package/src/utils/childProcess/spawn.js +1 -1
  150. package/src/utils/errorUtils.js +24 -3
  151. package/src/utils/invocationTraceDescriptions.js +43 -0
  152. package/src/utils/logger.js +1 -1
  153. package/src/utils/traceInvocationCall.js +21 -0
  154. package/src/utils/traceMethods.js +15 -0
  155. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
  156. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
  157. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
  158. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
  159. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
  160. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
  161. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
  162. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
  163. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar +0 -0
  164. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.md5 +0 -1
  165. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
  166. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
  167. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
  168. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom.md5 +0 -1
  169. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
  170. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
  171. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
  172. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
  173. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
  174. package/runners/jest/deprecation.js +0 -25
  175. package/src/configuration/utils/warnings.js +0 -12
  176. package/src/logger/DetoxTraceEventBuilder.js +0 -21
  177. package/src/logger/DetoxTracer.js +0 -133
  178. package/src/logger/TraceThreadDispatcher.js +0 -52
  179. package/src/utils/ChromeTracingExporter.js +0 -54
  180. package/src/utils/trace.js +0 -19
package/index.d.ts CHANGED
@@ -9,9 +9,9 @@
9
9
  // * Dor Ben Baruch <https://github.com/Dor256>
10
10
 
11
11
  import { BunyanDebugStreamOptions } from 'bunyan-debug-stream';
12
- import { EndHandle } from 'trace-event-lib';
13
12
 
14
13
  declare global {
14
+ const detox: Detox.DetoxExportWrapper;
15
15
  const device: Detox.DetoxExportWrapper['device'];
16
16
  const element: Detox.DetoxExportWrapper['element'];
17
17
  const waitFor: Detox.DetoxExportWrapper['waitFor'];
@@ -21,6 +21,7 @@ declare global {
21
21
 
22
22
  namespace NodeJS {
23
23
  interface Global {
24
+ detox: Detox.DetoxExportWrapper;
24
25
  device: Detox.DetoxExportWrapper['device'];
25
26
  element: Detox.DetoxExportWrapper['element'];
26
27
  waitFor: Detox.DetoxExportWrapper['waitFor'];
@@ -31,7 +32,7 @@ declare global {
31
32
  }
32
33
 
33
34
  namespace Detox {
34
- // region DetoxConfig
35
+ //#region DetoxConfig
35
36
 
36
37
  interface DetoxConfig extends DetoxConfigurationCommon {
37
38
  /**
@@ -81,15 +82,19 @@ declare global {
81
82
  */
82
83
  exposeGlobals?: boolean;
83
84
  /**
84
- * By default, Detox will uninstall and install the app upon the initialization.
85
+ * By default, Detox will uninstall and install the app upon initialization.
85
86
  * If you wish to reuse the existing app for a faster run, set the property to
86
87
  * `false`.
87
88
  */
88
89
  reinstallApp?: boolean;
89
90
  /**
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.
91
+ * When false, `detox test` command always deletes the shared lock file on start,
92
+ * assuming it had been left from the previous, already finished test session.
93
+ * The lock file contains information about busy and free devices and ensures
94
+ * no device can be used simultaneously by multiple test workers.
95
+ *
96
+ * Setting it to **true** might be useful when if you need to run multiple
97
+ * `detox test` commands in parallel, e.g. test a few configurations at once.
93
98
  *
94
99
  * @default false
95
100
  */
@@ -101,13 +106,43 @@ declare global {
101
106
  };
102
107
  }
103
108
 
109
+ type _DetoxLoggerOptions = Omit<BunyanDebugStreamOptions, 'out'>;
110
+
104
111
  interface DetoxLoggerConfig {
112
+ /**
113
+ * Log level filters the messages printed to your terminal,
114
+ * and it does not affect the logs written to the artifacts.
115
+ *
116
+ * Use `info` by default.
117
+ * Use `error` or warn when you want to make the output as silent as possible.
118
+ * Use `debug` to control what generally is happening under the hood.
119
+ * Use `trace` when troubleshooting specific issues.
120
+ *
121
+ * @default 'info'
122
+ */
105
123
  level?: DetoxLogLevel;
106
124
  /**
107
- * @default 'sandbox'
125
+ * When enabled, hijacks all the console methods (console.log, console.warn, etc)
126
+ * so that the messages printed via them are formatted and saved as Detox logs.
127
+ *
128
+ * @default true
129
+ */
130
+ overrideConsole?: boolean;
131
+ /**
132
+ * Since Detox is using
133
+ * {@link https://www.npmjs.com/package/bunyan-debug-stream bunyan-debug-stream}
134
+ * for printing logs, all its options are exposed for sake of simplicity
135
+ * of customization.
136
+ *
137
+ * The only exception is {@link BunyanDebugStreamOptions#out} option,
138
+ * which is always set to `process.stdout`.
139
+ *
140
+ * You can also pass a callback function to override the logger config
141
+ * programmatically, e.g. depending on the selected log level.
142
+ *
143
+ * @see {@link BunyanDebugStreamOptions}
108
144
  */
109
- overrideConsole?: 'all' | 'sandbox' | 'none';
110
- options?: BunyanDebugStreamOptions;
145
+ options?: _DetoxLoggerOptions | ((config: Partial<DetoxLoggerConfig>) => _DetoxLoggerOptions);
111
146
  }
112
147
 
113
148
  interface DetoxSessionConfig {
@@ -132,27 +167,110 @@ declare global {
132
167
  */
133
168
  [prop: string]: unknown;
134
169
  };
170
+
135
171
  /**
136
- * Configuration of custom integration features
137
- * between Detox and Jest
172
+ * This is an add-on section used by our Jest integration code (but not Detox core itself).
173
+ * In other words, if you’re implementing (or using) a custom integration with some other test runner, feel free to define a section for yourself (e.g. `testRunner.mocha`)
138
174
  */
139
175
  jest?: {
140
176
  /**
141
- * Device init timeout
177
+ * Environment setup timeout
178
+ *
179
+ * As a part of the environment setup, Detox boots the device and installs the apps.
180
+ * If that takes longer than the specified value, the entire test suite will be considered as failed, e.g.:
181
+ * ```plain text
182
+ * FAIL e2e/starter.test.js
183
+ * ● Test suite failed to run
184
+ *
185
+ * Exceeded timeout of 300000ms while setting up Detox environment
186
+ * ```
187
+ *
188
+ * The default value is 5 minutes.
189
+ *
190
+ * @default 300000
191
+ * @see {@link https://jestjs.io/docs/configuration/#testenvironment-string}
192
+ */
193
+ setupTimeout?: number | undefined;
194
+ /**
195
+ * Environemnt teardown timeout
196
+ *
197
+ * If the environment teardown takes longer than the specified value, Detox will throw a timeout error.
198
+ * The default value is half a minute.
199
+ *
200
+ * @default 30000 (30 seconds)
201
+ * @see {@link https://jestjs.io/docs/configuration/#testenvironment-string}
202
+ */
203
+ teardownTimeout?: number | undefined;
204
+ /**
205
+ * Jest provides an API to re-run individual failed tests: `jest.retryTimes(count)`.
206
+ * When Detox detects the use of this API, it suppresses its own CLI retry mechanism controlled via `detox test … --retries <N>` or {@link DetoxTestRunnerConfig#retries}.
207
+ * The motivation is simple – activating the both mechanisms is apt to increase your test duration dramatically, if your tests are flaky.
208
+ * If you wish nevertheless to use both the mechanisms simultaneously, set it to `true`.
209
+ *
210
+ * @default false
211
+ * @see {@link https://jestjs.io/docs/29.0/jest-object#jestretrytimesnumretries-options}
212
+ */
213
+ retryAfterCircusRetries?: boolean;
214
+ /**
215
+ * By default, Jest prints the test names and their status (_passed_ or _failed_) at the very end of the test session.
216
+ * When enabled, it makes Detox to print messages like these each time the new test starts and ends:
217
+ * ```plain text
218
+ * 18:03:36.258 detox[40125] i Sanity: should have welcome screen
219
+ * 18:03:37.495 detox[40125] i Sanity: should have welcome screen [OK]
220
+ * 18:03:37.496 detox[40125] i Sanity: should show hello screen after tap
221
+ * 18:03:38.928 detox[40125] i Sanity: should show hello screen after tap [OK]
222
+ * 18:03:38.929 detox[40125] i Sanity: should show world screen after tap
223
+ * 18:03:40.351 detox[40125] i Sanity: should show world screen after tap [OK]
224
+ * ```
225
+ * By default, it is enabled automatically in test sessions with a single worker.
226
+ * And vice versa, if multiple tests are executed concurrently, Detox turns it off to avoid confusion in the log.
227
+ * Use boolean values, `true` or `false`, to turn off the automatic choice.
228
+ *
229
+ * @default undefined
142
230
  */
143
- initTimeout?: number | undefined;
144
231
  reportSpecs?: boolean | undefined;
232
+ /**
233
+ * In the environment setup phase, Detox boots the device and installs the apps.
234
+ * This flag tells Detox to print messages like these every time the device gets assigned to a specific suite:
235
+ *
236
+ * ```plain text
237
+ * 18:03:29.869 detox[40125] i starter.test.js is assigned to 4EC84833-C7EA-4CA3-A6E9-5C30A29EA596 (iPhone 12 Pro Max)
238
+ * ```
239
+ *
240
+ * @default true
241
+ */
145
242
  reportWorkerAssign?: boolean | undefined;
146
243
  };
147
244
  /**
148
245
  * Retries count. Zero means a single attempt to run tests.
149
246
  */
150
247
  retries?: number;
248
+ /**
249
+ * When true, tells Detox CLI to cancel next retrying if it gets
250
+ * at least one report about a permanent test suite failure.
251
+ * Has no effect, if {@link DetoxTestRunnerConfig#retries} is
252
+ * undefined or set to zero.
253
+ *
254
+ * @default false
255
+ * @see {DetoxInternals.DetoxTestFileReport#isPermanentFailure}
256
+ */
257
+ bail?: boolean;
151
258
  /**
152
259
  * Custom handler to process --inspect-brk CLI flag.
153
- * Use it when you rely on another test runner than Jest.
260
+ * Use it when you rely on another test runner than Jest to mutate the config.
261
+ */
262
+ inspectBrk?: (config: DetoxTestRunnerConfig) => void;
263
+ /**
264
+ * Forward environment variables to the spawned test runner
265
+ * accordingly to the given CLI argument overrides.
266
+ *
267
+ * If false, Detox CLI will be only printing a hint message on
268
+ * how to start the test runner using environment variables,
269
+ * in case when a user wants to avoid using Detox CLI.
270
+ *
271
+ * @default false
154
272
  */
155
- inspectBrk?: boolean | ((config: DetoxTestRunnerConfig) => void);
273
+ forwardEnv?: boolean;
156
274
  }
157
275
 
158
276
  type DetoxAppConfig = (DetoxBuiltInAppConfig | DetoxCustomAppConfig) & {
@@ -223,6 +341,13 @@ declare global {
223
341
  build?: string;
224
342
  testBinaryPath?: string;
225
343
  launchArgs?: Record<string, any>;
344
+ /**
345
+ * TCP ports to `adb reverse` upon the installation.
346
+ * E.g. 8081 - to be able to access React Native packager in Debug mode.
347
+ *
348
+ * @example [8081]
349
+ */
350
+ reversePorts?: number[];
226
351
  }
227
352
 
228
353
  interface DetoxCustomAppConfig {
@@ -283,8 +408,6 @@ declare global {
283
408
  os: string;
284
409
  }
285
410
 
286
- type DetoxKnownDeviceType = DetoxBuiltInDeviceConfig['type'];
287
-
288
411
  type DetoxConfiguration = DetoxConfigurationCommon & (
289
412
  | DetoxConfigurationSingleApp
290
413
  | DetoxConfigurationMultiApps
@@ -304,7 +427,7 @@ declare global {
304
427
 
305
428
  type DetoxAliasedApp = string | DetoxAppConfig;
306
429
 
307
- // endregion DetoxConfig
430
+ //#endregion
308
431
 
309
432
  interface DetoxExportWrapper {
310
433
  readonly device: Device;
@@ -339,64 +462,81 @@ declare global {
339
462
  readonly log: Logger;
340
463
 
341
464
  /**
465
+ * @deprecated
466
+ *
467
+ * Deprecated - use {@link Detox.Logger#trace}
342
468
  * Detox tracer instance. Can be used for building timelines in Google Event Tracing format.
343
469
  */
344
- readonly trace: Tracer;
470
+ readonly trace: {
471
+ /** @deprecated */
472
+ readonly startSection: (name: string) => void;
473
+ /** @deprecated */
474
+ readonly endSection: (name: string) => void;
475
+ };
345
476
 
346
477
  /**
478
+ * Trace a single call, with a given name and arguments.
479
+ *
347
480
  * @deprecated
481
+ * @param sectionName The name of the section to trace.
482
+ * @param promiseOrFunction Promise or a function that provides a promise.
483
+ * @param args Optional arguments to pass to the trace.
484
+ * @returns The returned value of the traced call.
485
+ * @see https://wix.github.io/Detox/docs/19.x/api/detox-object-api/#detoxtracecall
348
486
  */
349
- readonly traceCall: _TraceCallSignature;
487
+ readonly traceCall: <T>(event: string, action: () => Promise<T>, args?: Record<string, unknown>) => Promise<T>;
350
488
  }
351
489
 
352
- /** @internal */
353
- type _TraceEventArgs = Record<string, unknown>;
490
+ interface Logger {
491
+ readonly level: DetoxLogLevel;
354
492
 
355
- type TraceEvent = {
356
- name?: string;
357
- cat?: string;
358
- cname?: string;
359
- id?: number;
360
- args?: _TraceEventArgs;
361
- };
493
+ readonly fatal: _LogMethod;
494
+ readonly error: _LogMethod;
495
+ readonly warn: _LogMethod;
496
+ readonly info: _LogMethod;
497
+ readonly debug: _LogMethod;
498
+ readonly trace: _LogMethod;
362
499
 
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>;
500
+ child(context?: Partial<LogEvent>): Logger;
371
501
  }
372
502
 
373
503
  /** @internal */
374
- interface _TraceSectionSignature<T> {
375
- (event?: string, args?: _TraceEventArgs): T;
376
- (event: TraceEvent): T;
504
+ interface _LogMethod extends _LogMethodSignature {
505
+ readonly begin: _LogMethodSignature;
506
+ readonly complete: _CompleteMethodSignature;
507
+ readonly end: _LogMethodSignature;
377
508
  }
378
509
 
379
- interface Tracer extends _TraceCallSignature {
380
- readonly begin: _TraceSectionSignature<EndHandle<{ cname: string; args: _TraceEventArgs; }>>;
381
- readonly end: _TraceSectionSignature<void>;
510
+ /** @internal */
511
+ interface _LogMethodSignature {
512
+ (...args: unknown[]): void
513
+ (event: LogEvent, ...args: unknown[]): void;
514
+ }
382
515
 
383
- /** @deprecated */
384
- readonly startSection: _TraceSectionSignature<void>;
385
- /** @deprecated */
386
- readonly endSection: _TraceSectionSignature<void>;
516
+ /** @internal */
517
+ interface _CompleteMethodSignature {
518
+ <T>(message: string, action: T | (() => T)): T;
519
+ <T>(event: LogEvent, message: string, action: T | (() => T)): T;
387
520
  }
388
521
 
389
- type Logger = {
390
- readonly level: DetoxLogLevel;
522
+ type LogEvent = {
523
+ /** Use when there's a risk of logging several parallel duration events. */
524
+ id?: string | number;
525
+ /** Optional. Event categories (tags) to facilitate filtering. */
526
+ cat?: string | string[];
527
+ /** Optional. Color name (applicable in Google Chrome Trace Format) */
528
+ cname?: string;
391
529
 
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;
530
+ /** Reserved property. Process ID. */
531
+ pid?: never;
532
+ /** Reserved property. Thread ID. */
533
+ tid?: never;
534
+ /** Reserved property. Timestamp. */
535
+ ts?: never;
536
+ /** Reserved property. Event phase. */
537
+ ph?: never;
398
538
 
399
- child(context?: Record<string, unknown>): Logger;
539
+ [customProperty: string]: unknown;
400
540
  };
401
541
 
402
542
  type DetoxLogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
@@ -539,10 +679,11 @@ declare global {
539
679
  * Relaunch the app. Convenience method that calls {@link Device#launchApp}
540
680
  * with { newInstance: true } override.
541
681
  *
682
+ * @deprecated
542
683
  * @param config
543
684
  * @see Device#launchApp
544
685
  */
545
- relaunchApp(config?: Omit<DeviceLaunchAppConfig, 'newInstance'>): Promise<void>;
686
+ relaunchApp(config?: DeviceLaunchAppConfig): Promise<void>;
546
687
 
547
688
  /**
548
689
  * Access the user-defined launch-arguments predefined through static scopes such as the Detox configuration file and