detox 20.0.14-is-hittable-over-master.0 → 20.0.14-prerelease.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar} +0 -0
  12. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.md5 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.md5} +0 -0
  13. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.sha1 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.sha1} +0 -0
  14. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.sha256 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.sha256} +0 -0
  15. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.sha512 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.sha512} +0 -0
  16. package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.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 +0 -1
  29. package/android/detox/proguard-rules-app.pro +4 -2
  30. package/index.d.ts +105 -19
  31. package/internals.d.ts +103 -22
  32. package/local-cli/cli.js +1 -1
  33. package/local-cli/init.js +1 -1
  34. package/local-cli/test.js +6 -6
  35. package/local-cli/test.test.js +41 -41
  36. package/local-cli/testCommand/TestRunnerCommand.js +75 -78
  37. package/local-cli/testCommand/builder.js +0 -1
  38. package/local-cli/testCommand/middlewares.js +1 -11
  39. package/local-cli/testCommand/warnings.js +0 -3
  40. package/local-cli/utils/jestInternals.js +4 -1
  41. package/package.json +27 -13
  42. package/runners/deprecation.js +42 -44
  43. package/runners/jest/index.d.ts +60 -0
  44. package/runners/jest/index.js +3 -8
  45. package/runners/jest/reporters/DetoxReporter.js +21 -10
  46. package/runners/jest/testEnvironment/index.js +57 -41
  47. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +7 -3
  48. package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
  49. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
  50. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  51. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
  52. package/src/DetoxWorker.js +95 -55
  53. package/src/artifacts/ArtifactsManager.js +6 -24
  54. package/src/configuration/collectCliConfig.js +1 -12
  55. package/src/configuration/composeLoggerConfig.js +2 -2
  56. package/src/configuration/composeRunnerConfig.js +8 -6
  57. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
  58. package/src/errors/DetoxConfigErrorComposer.js +6 -1
  59. package/src/ipc/SessionState.js +8 -6
  60. package/src/logger/DetoxLogger.js +5 -25
  61. package/src/logger/index.js +1 -0
  62. package/src/logger/utils/CategoryThreadDispatcher.js +7 -29
  63. package/src/logger/utils/DetoxLogFinalizer.js +134 -0
  64. package/src/logger/utils/ThreadDispatcher.js +5 -25
  65. package/src/logger/utils/customConsoleLogger.js +4 -3
  66. package/src/logger/utils/streamUtils.js +34 -26
  67. package/src/realms/DetoxContext.js +10 -13
  68. package/src/realms/DetoxInternalsFacade.js +0 -6
  69. package/src/realms/DetoxPrimaryContext.js +29 -84
  70. package/src/realms/DetoxSecondaryContext.js +6 -10
  71. package/src/symbols.js +0 -12
  72. package/src/utils/argparse.js +11 -0
  73. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.md5 +0 -1
  74. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.sha1 +0 -1
  75. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.sha256 +0 -1
  76. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.sha512 +0 -1
  77. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.md5 +0 -1
  78. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.sha1 +0 -1
  79. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.sha256 +0 -1
  80. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.sha512 +0 -1
  81. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.md5 +0 -1
  82. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.sha1 +0 -1
  83. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.sha256 +0 -1
  84. package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.sha512 +0 -1
  85. package/runners/jest/deprecation.js +0 -25
  86. package/src/configuration/utils/warnings.js +0 -12
@@ -0,0 +1 @@
1
+ 31332781d3002ae93a1eaec77474e9f55bc7e5c7
@@ -0,0 +1 @@
1
+ dcdfc5160bc82d542532fabc0b278164e550b9df0fc3f7a5afe6beaff60701f5
@@ -0,0 +1 @@
1
+ 71f4200bf6199efed9fb74fb1cd92570ed90abbe4bdf7c37816571c49af0d0559fcb943eafac23fd3a4e4004b822bb2248e062185df77ea13110acc9b0a4c26d
@@ -0,0 +1 @@
1
+ 04ee086f0aed13fd42de03340cc5c1d8d8749f6d
@@ -0,0 +1 @@
1
+ 904c995d85c623ebe69096dba272c0e855d99b96c9997dfb2f4a2321b603356e
@@ -0,0 +1 @@
1
+ fc2b80324b5b497e17a4e9adf5d7b06d003fca036559e7e61b39b8777e9238377e182f0959e54ee452053538fa1b17d65537158ed952b8b99e995d2fde590b0f
@@ -3,7 +3,7 @@
3
3
  <modelVersion>4.0.0</modelVersion>
4
4
  <groupId>com.wix</groupId>
5
5
  <artifactId>detox</artifactId>
6
- <version>20.0.14-is-hittable-over-master.0</version>
6
+ <version>20.0.14-prerelease.0</version>
7
7
  <packaging>aar</packaging>
8
8
  <name>Detox</name>
9
9
  <description>Gray box end-to-end testing and automation library for mobile apps</description>
@@ -0,0 +1 @@
1
+ 8bd920eb4542d031002c33d93308f426
@@ -0,0 +1 @@
1
+ 914ef3c1658d24794b7b94393578d899b16c0ed0
@@ -0,0 +1 @@
1
+ a9b0b7bda22739644dee243f227c20d956ea3294378f75dea8d0f3d0d861d559
@@ -0,0 +1 @@
1
+ 523b294c136c5be73335a2c75f3ebb8bce7aa79579810a7cd96cb28a69e000043dbf188b44e30b06ee5762fead96255c3efd272ab4d9a8691428510e055160d5
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.0.14-is-hittable-over-master.0</latest>
7
- <release>20.0.14-is-hittable-over-master.0</release>
6
+ <latest>20.0.14-prerelease.0</latest>
7
+ <release>20.0.14-prerelease.0</release>
8
8
  <versions>
9
- <version>20.0.14-is-hittable-over-master.0</version>
9
+ <version>20.0.14-prerelease.0</version>
10
10
  </versions>
11
- <lastUpdated>20221106162428</lastUpdated>
11
+ <lastUpdated>20221108145605</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 36f4a2be3d5428adbd7ef7d9d658caf2
1
+ ba7d8cb5496d1d9366a8234bc4e64055
@@ -1 +1 @@
1
- e3d9c2e702cf221804d9e08ef5474c31acaa2a97
1
+ 77f004770bdd78a7442584a10dd84ef431783841
@@ -1 +1 @@
1
- 77786aeb086510b2a6cd1ad411cbf3ae648ddd7f66f2265ae53fb2e917e7eb6c
1
+ dd9c1791bb2c603c4806ebca0b071f52229edadedc9e487d52a434c1c24638b7
@@ -1 +1 @@
1
- 551879251459e011fb04bc7be88d05705f47603ee1495f16524386ea26f7b1c4462dbfe6c4b916f6da5499a2d1f6ea98f97714a65e713e8fa9b563e4bc17e075
1
+ a2914ac9dc6c4bd7a1f84a46a8f84e467d314b71f96d6603c4303bc54344d354fdc2903e1934c275ee785cd4a544c7a7f575c512ad6b623b76f943b672be718c
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
@@ -37,7 +37,6 @@ allprojects {
37
37
  mavenLocal()
38
38
  mavenCentral()
39
39
  google()
40
- jcenter()
41
40
  maven {
42
41
  url "$projectDir/../../node_modules/react-native/android"
43
42
  }
@@ -1,4 +1,5 @@
1
1
  -keepattributes InnerClasses, Exceptions
2
+
2
3
  -keep class com.facebook.react.modules.** { *; }
3
4
  -keep class com.facebook.react.uimanager.** { *; }
4
5
  -keep class com.facebook.react.animated.** { *; }
@@ -8,8 +9,9 @@
8
9
  -keep class com.facebook.react.ReactInstanceManager** { *; }
9
10
  -keep class com.facebook.react.ReactInstanceEventListener { *; }
10
11
 
11
- -keep class com.facebook.react.views.slider.ReactSlider { *; }
12
- -keep class com.reactnativecommunity.slider.ReactSlider { *; }
12
+ -keep class com.facebook.react.views.slider.** { *; }
13
+ -keep class com.google.android.material.slider.** { *; }
14
+ -keep class com.reactnativecommunity.slider.** { *; }
13
15
  -keep class com.reactnativecommunity.asyncstorage.** { *; }
14
16
 
15
17
  -keep class kotlin.jvm.** { *; }
package/index.d.ts CHANGED
@@ -32,7 +32,7 @@ declare global {
32
32
  }
33
33
 
34
34
  namespace Detox {
35
- // region DetoxConfig
35
+ //#region DetoxConfig
36
36
 
37
37
  interface DetoxConfig extends DetoxConfigurationCommon {
38
38
  /**
@@ -82,15 +82,19 @@ declare global {
82
82
  */
83
83
  exposeGlobals?: boolean;
84
84
  /**
85
- * By default, Detox will uninstall and install the app upon the initialization.
85
+ * By default, Detox will uninstall and install the app upon initialization.
86
86
  * If you wish to reuse the existing app for a faster run, set the property to
87
87
  * `false`.
88
88
  */
89
89
  reinstallApp?: boolean;
90
90
  /**
91
- * If you wish to run multiple "detox test" commands in parallel,
92
- * make sure they don't delete the shared lock file only the
93
- * 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.
94
98
  *
95
99
  * @default false
96
100
  */
@@ -102,13 +106,43 @@ declare global {
102
106
  };
103
107
  }
104
108
 
109
+ type _DetoxLoggerOptions = Omit<BunyanDebugStreamOptions, 'out'>;
110
+
105
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
+ */
106
123
  level?: DetoxLogLevel;
107
124
  /**
108
- * @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}
109
144
  */
110
- overrideConsole?: 'all' | 'sandbox' | 'none';
111
- options?: BunyanDebugStreamOptions | ((config: Partial<DetoxLoggerConfig>) => BunyanDebugStreamOptions);
145
+ options?: _DetoxLoggerOptions | ((config: Partial<DetoxLoggerConfig>) => _DetoxLoggerOptions);
112
146
  }
113
147
 
114
148
  interface DetoxSessionConfig {
@@ -133,25 +167,78 @@ declare global {
133
167
  */
134
168
  [prop: string]: unknown;
135
169
  };
170
+
136
171
  /**
137
- * Configuration of custom integration features
138
- * 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`)
139
174
  */
140
175
  jest?: {
141
176
  /**
142
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}
143
192
  */
144
193
  setupTimeout?: number | undefined;
145
194
  /**
146
- * Environment teardown timeout
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}
147
202
  */
148
203
  teardownTimeout?: number | undefined;
149
204
  /**
150
- * Insist on CLI-based retry mechanism even when the failed tests have been handled
151
- * by jest.retryTimes(n) mechanism from Jest Circus.
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}
152
212
  */
153
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
230
+ */
154
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
+ */
155
242
  reportWorkerAssign?: boolean | undefined;
156
243
  };
157
244
  /**
@@ -170,9 +257,9 @@ declare global {
170
257
  bail?: boolean;
171
258
  /**
172
259
  * Custom handler to process --inspect-brk CLI flag.
173
- * 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.
174
261
  */
175
- inspectBrk?: boolean | ((config: DetoxTestRunnerConfig) => void);
262
+ inspectBrk?: (config: DetoxTestRunnerConfig) => void;
176
263
  /**
177
264
  * Forward environment variables to the spawned test runner
178
265
  * accordingly to the given CLI argument overrides.
@@ -321,8 +408,6 @@ declare global {
321
408
  os: string;
322
409
  }
323
410
 
324
- type DetoxKnownDeviceType = DetoxBuiltInDeviceConfig['type'];
325
-
326
411
  type DetoxConfiguration = DetoxConfigurationCommon & (
327
412
  | DetoxConfigurationSingleApp
328
413
  | DetoxConfigurationMultiApps
@@ -342,7 +427,7 @@ declare global {
342
427
 
343
428
  type DetoxAliasedApp = string | DetoxAppConfig;
344
429
 
345
- // endregion DetoxConfig
430
+ //#endregion
346
431
 
347
432
  interface DetoxExportWrapper {
348
433
  readonly device: Device;
@@ -596,10 +681,11 @@ declare global {
596
681
  * Relaunch the app. Convenience method that calls {@link Device#launchApp}
597
682
  * with { newInstance: true } override.
598
683
  *
684
+ * @deprecated
599
685
  * @param config
600
686
  * @see Device#launchApp
601
687
  */
602
- relaunchApp(config?: Omit<DeviceLaunchAppConfig, 'newInstance'>): Promise<void>;
688
+ relaunchApp(config?: DeviceLaunchAppConfig): Promise<void>;
603
689
 
604
690
  /**
605
691
  * Access the user-defined launch-arguments predefined through static scopes such as the Detox configuration file and
package/internals.d.ts CHANGED
@@ -6,52 +6,113 @@ declare global {
6
6
  type DetoxStatus = 'inactive' | 'init' | 'active' | 'cleanup';
7
7
 
8
8
  type Facade = {
9
- // region Initialization
9
+ //#region Initialization
10
10
  /**
11
11
  * Use with a caution, when you still have no config, yet need to avoid {@link Facade#init}
12
12
  */
13
13
  resolveConfig(options?: Partial<DetoxInitOptions>): Promise<RuntimeConfig>;
14
14
 
15
15
  /**
16
+ * Returns one of statuses depending on what’s going with the current Detox context:
16
17
  *
18
+ * `inactive` – before `init()` and after `cleanup()` is called.
19
+ * `init` – while `init()` is executing.
20
+ * `active` – after `init()` and before `cleanup()` is called.
21
+ * `cleanup` – while `cleanup()` is executing.
17
22
  */
18
23
  getStatus(): DetoxStatus;
19
24
 
20
25
  /**
21
- * This is the phase where Detox reads its configuration, starts a server.
26
+ * Starts a new Detox test session with the provided configuration.
27
+ * See {@link https://wix.github.io/Detox/docs/next/api/internals} for more details.
22
28
  */
23
29
  init(options?: Partial<DetoxInitOptions>): Promise<void>;
24
30
 
25
31
  /**
26
- * This is the phase where Detox loads its expectation library and starts a device.
32
+ * This is the phase where Detox loads its expectation library and boots a device.
33
+ * You don't need to call it separately unless you use `init({ workerId: null })` override.
27
34
  */
28
35
  installWorker(options?: Partial<DetoxInstallWorkerOptions>): Promise<void>;
29
36
 
30
37
  /**
31
38
  * Deallocates the device.
39
+ * Most Client API (device, by, element, expect) will stop working, except for the logger.
32
40
  */
33
41
  uninstallWorker(): Promise<void>;
34
42
 
35
43
  /**
36
- * The global cleanup phase should happen after all the tests have finished.
37
- * This is the phase where the Detox server shuts down.
44
+ * This method should be called when the main or child process is about to exit.
45
+ * See {@link https://wix.github.io/Detox/docs/next/api/internals} for more details.
38
46
  */
39
47
  cleanup(): Promise<void>;
40
- // endregion
41
-
42
- // region Lifecycle
43
- onRunStart(event: unknown): Promise<void>;
44
- onRunDescribeStart(event: unknown): Promise<void>;
45
- onTestStart(event: unknown): Promise<void>;
46
- onHookStart(event: unknown): Promise<void>;
47
- onHookFailure(event: unknown): Promise<void>;
48
- onHookSuccess(event: unknown): Promise<void>;
49
- onTestFnStart(event: unknown): Promise<void>;
50
- onTestFnFailure(event: unknown): Promise<void>;
51
- onTestFnSuccess(event: unknown): Promise<void>;
52
- onTestDone(event: unknown): Promise<void>;
53
- onRunDescribeFinish(event: unknown): Promise<void>;
54
- onRunFinish(event: unknown): Promise<void>;
48
+ //#endregion
49
+
50
+ //#region Lifecycle
51
+ /**
52
+ * Reports that the test runner started executing a test suite, e.g. a `beforeAll` hook or a first test.
53
+ */
54
+ onRunDescribeStart(event: {
55
+ /** Test suite name */
56
+ name: string;
57
+ }): Promise<void>;
58
+ /**
59
+ * Reports that the test runner started executing a specific test.
60
+ */
61
+ onTestStart(event: {
62
+ /** Test name */
63
+ title: string;
64
+ /** Test name including the ancestor suite titles */
65
+ fullName: string;
66
+ /**
67
+ * N-th time this test is running, if there is a retry mechanism.
68
+ *
69
+ * @default 1
70
+ */
71
+ invocations?: number;
72
+ status: 'running';
73
+ }): Promise<void>;
74
+ /**
75
+ * Reports about an error in the midst of `beforeAll`, `beforeEach`, `afterEach`, `afterAll` or any other hook.
76
+ */
77
+ onHookFailure(event: {
78
+ error: Error | string;
79
+ /**
80
+ * @example 'beforeAll'
81
+ * @example 'afterEach'
82
+ */
83
+ hook: string;
84
+ }): Promise<void>;
85
+ /**
86
+ * Reports about an error in the midst of a test function, `test` or `it`.
87
+ */
88
+ onTestFnFailure(event: {
89
+ error: Error | string;
90
+ }): Promise<void>;
91
+ /**
92
+ * Reports the final status of the test, `passed` or `failed`.
93
+ */
94
+ onTestDone(event: {
95
+ /** Test name */
96
+ title: string;
97
+ /** Test name including the ancestor suite titles */
98
+ fullName: string;
99
+ /**
100
+ * N-th time this test is running, if there is a retry mechanism.
101
+ *
102
+ * @default 1
103
+ */
104
+ invocations?: number;
105
+ status: 'passed' | 'failed';
106
+ /** Whether a timeout was the reason for why the test failed. */
107
+ timedOut?: boolean;
108
+ }): Promise<void>;
109
+ /**
110
+ * Reports that the test runner has finished executing a test suite, e.g. all the `afterAll` hooks have been executed or the last test has finished running.
111
+ */
112
+ onRunDescribeFinish(event: {
113
+ /** Test suite name */
114
+ name: string;
115
+ }): Promise<void>;
55
116
 
56
117
  /**
57
118
  * Reports to Detox CLI about passed and failed test files.
@@ -61,7 +122,7 @@ declare global {
61
122
  * @param testResults - reports about test files
62
123
  */
63
124
  reportTestResults(testResults: DetoxTestFileReport[]): Promise<void>;
64
- // endregion
125
+ //#endregion
65
126
 
66
127
  readonly config: RuntimeConfig;
67
128
  readonly log: Detox.Logger;
@@ -78,6 +139,10 @@ declare global {
78
139
  createEventStream(): NodeJS.ReadableStream;
79
140
  };
80
141
 
142
+ /**
143
+ * Not documented on purpose.
144
+ * Provides direct access to the object which holds the device driver, websocket client, matchers, expectations, etc.
145
+ */
81
146
  readonly worker: Worker;
82
147
  }
83
148
 
@@ -87,6 +152,9 @@ declare global {
87
152
 
88
153
  type DetoxInitOptions = {
89
154
  cwd: string;
155
+ /**
156
+ * @internal
157
+ */
90
158
  argv: Record<string, unknown>;
91
159
  testRunnerArgv: Record<string, unknown>;
92
160
  override: Partial<Detox.DetoxConfig>;
@@ -174,7 +242,7 @@ declare global {
174
242
  * or equal to "default" if the name is not configured.
175
243
  */
176
244
  apps: Record<string, Readonly<Detox.DetoxAppConfig>>;
177
- artifacts: Readonly<Detox.DetoxArtifactsConfig>;
245
+ artifacts: Readonly<RuntimeArtifactsConfig>;
178
246
  behavior: Readonly<Detox.DetoxBehaviorConfig>;
179
247
  cli: Readonly<CLIConfig>;
180
248
  device: Readonly<Detox.DetoxDeviceConfig>;
@@ -183,6 +251,19 @@ declare global {
183
251
  session: Readonly<Detox.DetoxSessionConfig>;
184
252
  }>;
185
253
 
254
+ type RuntimeArtifactsConfig = {
255
+ rootDir: string;
256
+ pathBuilder: string;
257
+ plugins: Readonly<{
258
+ log: Readonly<Detox.DetoxLogArtifactsPluginConfig>;
259
+ screenshot: Readonly<Detox.DetoxScreenshotArtifactsPluginConfig>;
260
+ video: Readonly<Detox.DetoxVideoArtifactsPluginConfig>;
261
+ instruments: Readonly<Detox.DetoxInstrumentsArtifactsPluginConfig>;
262
+ uiHierarchy: Readonly<Detox.DetoxUIHierarchyArtifactsPluginConfig>;
263
+ [pluginId: string]: unknown;
264
+ }>;
265
+ };
266
+
186
267
  type CLIConfig = Readonly<Partial<{
187
268
  appLaunchArgs: string;
188
269
  artifactsLocation: string;
package/local-cli/cli.js CHANGED
@@ -30,7 +30,7 @@ yargs
30
30
  if (err) {
31
31
  logger.error(DetoxError.format(err));
32
32
  // eslint-disable-next-line no-console
33
- console.error('');
33
+ process.stderr.write('\n');
34
34
  // @ts-ignore
35
35
  _.attempt(() => fs.unlinkSync(logger.file));
36
36
  // eslint-disable-next-line no-process-exit
package/local-cli/init.js CHANGED
@@ -9,7 +9,7 @@ const jestTemplates = require('./templates/jest');
9
9
  let exitCode = 0;
10
10
 
11
11
  module.exports.command = 'init';
12
- module.exports.desc = 'Scaffold initial E2E test folder structure for Detox';
12
+ module.exports.desc = 'Creates template files to get you started with Detox';
13
13
  module.exports.builder = {};
14
14
 
15
15
  module.exports.handler = async function init() {
package/local-cli/test.js CHANGED
@@ -3,7 +3,7 @@ const detox = require('../internals');
3
3
  const TestRunnerCommand = require('./testCommand/TestRunnerCommand');
4
4
 
5
5
  module.exports.command = 'test';
6
- module.exports.desc = 'Run your test suite with the test runner specified in package.json';
6
+ module.exports.desc = 'Run your test suites with the test runner specified in the project\'s Detox config';
7
7
  module.exports.builder = require('./testCommand/builder');
8
8
  module.exports.middlewares = require('./testCommand/middlewares').default;
9
9
 
@@ -16,14 +16,14 @@ module.exports.handler = async function test({ detoxArgs, runnerArgs }) {
16
16
  };
17
17
 
18
18
  const config = await detox.resolveConfig(opts);
19
- if (!config.testRunner.inspectBrk) {
19
+ if (!config.cli.inspectBrk) {
20
20
  await detox.init(opts);
21
21
  }
22
22
 
23
- const runnerCommand = new TestRunnerCommand()
24
- .setDeviceConfig(detox.config.device)
25
- .replicateCLIConfig(detox.config.cli)
26
- .setRunnerConfig(detox.config.testRunner);
23
+ const runnerCommand = new TestRunnerCommand({
24
+ config,
25
+ env: process.env,
26
+ });
27
27
 
28
28
  await runnerCommand.execute();
29
29
  } finally {