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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. 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 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
  6. 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 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-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 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-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 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.md5} +0 -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 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha1} +0 -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 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha256} +0 -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 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha512} +0 -0
  16. package/Detox-android/com/wix/detox/{20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-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/index.d.ts +49 -40
  29. package/internals.d.ts +75 -22
  30. package/local-cli/build.js +1 -1
  31. package/local-cli/build.test.js +14 -14
  32. package/local-cli/cli.js +1 -1
  33. package/local-cli/rebuild-framework-cache.js +1 -1
  34. package/local-cli/test.js +6 -5
  35. package/local-cli/test.test.js +2 -2
  36. package/local-cli/testCommand/TestRunnerCommand.js +4 -3
  37. package/package.json +5 -4
  38. package/runners/jest/globalSetup.js +1 -1
  39. package/runners/jest/globalTeardown.js +1 -1
  40. package/runners/jest/testEnvironment/index.js +34 -17
  41. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +78 -43
  42. package/runners/jest/testEnvironment/listeners/SpecReporter.js +2 -2
  43. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +2 -2
  44. package/src/DetoxWorker.js +11 -2
  45. package/src/artifacts/ArtifactsManager.js +8 -23
  46. package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
  47. package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
  48. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
  49. package/src/artifacts/templates/artifact/Artifact.js +1 -1
  50. package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
  51. package/src/artifacts/utils/temporaryPath.js +18 -7
  52. package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
  53. package/src/client/AsyncWebSocket.js +8 -17
  54. package/src/client/Client.js +1 -1
  55. package/src/configuration/collectCliConfig.js +1 -1
  56. package/src/configuration/composeDeviceConfig.js +1 -1
  57. package/src/configuration/composeLoggerConfig.js +17 -8
  58. package/src/configuration/composeRunnerConfig.js +49 -2
  59. package/src/configuration/index.js +14 -9
  60. package/src/configuration/loadExternalConfig.js +1 -1
  61. package/src/devices/allocation/DeviceAllocator.js +3 -2
  62. package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +1 -1
  63. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +3 -2
  64. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
  65. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -2
  66. package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
  67. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
  68. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
  69. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
  70. package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  71. package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
  72. package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
  73. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
  74. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +9 -13
  75. package/src/devices/runtime/RuntimeDevice.js +7 -8
  76. package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
  77. package/src/devices/runtime/drivers/android/AndroidDriver.js +1 -1
  78. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
  79. package/src/errors/DetoxConfigErrorComposer.js +4 -2
  80. package/src/ipc/IPCClient.js +3 -8
  81. package/src/ipc/IPCServer.js +11 -11
  82. package/src/ipc/{state.js → SessionState.js} +23 -50
  83. package/src/logger/DetoxLogger.js +264 -155
  84. package/src/logger/index.js +4 -0
  85. package/src/logger/utils/BunyanLogger.js +72 -0
  86. package/src/logger/utils/CategoryThreadDispatcher.js +58 -0
  87. package/src/logger/utils/MessageStack.js +24 -0
  88. package/src/logger/{TraceThreadDispatcher.js → utils/ThreadDispatcher.js} +34 -5
  89. package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +4 -4
  90. package/src/logger/utils/sanitizeBunyanContext.js +28 -0
  91. package/src/logger/utils/tracerLegacy.js +25 -0
  92. package/src/realms/DetoxContext.js +65 -57
  93. package/src/realms/DetoxInternalsFacade.js +7 -5
  94. package/src/realms/DetoxPrimaryContext.js +118 -41
  95. package/src/realms/DetoxSecondaryContext.js +31 -30
  96. package/src/server/DetoxConnection.js +18 -23
  97. package/src/server/DetoxServer.js +7 -10
  98. package/src/server/DetoxSession.js +6 -6
  99. package/src/server/DetoxSessionManager.js +1 -1
  100. package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
  101. package/src/symbols.js +12 -8
  102. package/src/utils/childProcess/exec.js +1 -1
  103. package/src/utils/childProcess/spawn.js +1 -1
  104. package/src/utils/streamUtils.js +10 -11
  105. package/src/utils/trace.js +2 -18
  106. package/src/utils/traceMethods.js +15 -0
  107. 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 +0 -1
  108. 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 +0 -1
  109. 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 +0 -1
  110. 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 +0 -1
  111. 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 +0 -1
  112. 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 +0 -1
  113. 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 +0 -1
  114. 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 +0 -1
  115. 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 +0 -1
  116. 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 +0 -1
  117. 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 +0 -1
  118. 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 +0 -1
  119. package/src/logger/DetoxTraceEventBuilder.js +0 -21
  120. package/src/logger/DetoxTracer.js +0 -133
  121. package/src/utils/ChromeTracingExporter.js +0 -54
@@ -0,0 +1 @@
1
+ 274e47fbbdbe85abdf2ebfd4c76e00ef33ad353309da375460f71f9f6fe04c2a
@@ -0,0 +1 @@
1
+ 063f4a5549133b4d661a7677d68a91473877b26ed3e29ef9d7502a83c179810d68f15dd9e35399b5bab23f3c97f96ee875a80abcb07d1dfa57a6177399dcc347
@@ -0,0 +1 @@
1
+ 4a344c3b3b5597488fece53c9cc7358705e6d40116b0779122428094bd021db7
@@ -0,0 +1 @@
1
+ 93443f0d56c9f84ec24523b954e6e9782652c4bd5d8c94bf558812fade6750beb49f4678dcbaef53e1948edcf5fb5e35c47efb49c7acc79cd2ffa0fea2b287bd
@@ -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.2-breaking.new-global-lifecycle.0</version>
6
+ <version>20.0.5-breaking.new-global-lifecycle.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
+ b9ea5a9228c8248ce58fcfc5eb12983b642c2240ae61fd0929cfdafb664cc9a6
@@ -0,0 +1 @@
1
+ 7d5986795398d9c6021a9d4085a4e1b2c3e794e51fb873ddfefc596d2f8b3a04a58c553fdb4202f6bd5fa4bbbf36373b318a7497a66e345b6f8f23bfee8b4145
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.0.2-breaking.new-global-lifecycle.0</latest>
7
- <release>20.0.2-breaking.new-global-lifecycle.0</release>
6
+ <latest>20.0.5-breaking.new-global-lifecycle.0</latest>
7
+ <release>20.0.5-breaking.new-global-lifecycle.0</release>
8
8
  <versions>
9
- <version>20.0.2-breaking.new-global-lifecycle.0</version>
9
+ <version>20.0.5-breaking.new-global-lifecycle.0</version>
10
10
  </versions>
11
- <lastUpdated>20220812072754</lastUpdated>
11
+ <lastUpdated>20220904154935</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 66edf73eb985206d4b25467aaf398b5b
1
+ 90746dab45626ae5891c33be157b7921
@@ -1 +1 @@
1
- f08d44468bdd0e4ae5efdcfe2ce7607e2b89b953
1
+ 81eeaefaf3b36e2c9883bcf08e42f41532e2007a
@@ -1 +1 @@
1
- d51a7e909a7633013fa58ab30ca34ed484b2b67acbd7f0484c923f04bdeb2ec6
1
+ 07a51f70f99dd28e9f3bee0eb85dbb265fc16087a96ebed98c654855c2cca88b
@@ -1 +1 @@
1
- 04a047b23b9ed5229c4f124c08719bb7e1b468cc5fab450a9403adfd7f7c109ebae29182f6c3763e9b7915c4ff60c5971ea8f8417e8d5b8b7877961310c1f484
1
+ 01e0caff588c876ccc96cbad6c8d317178f6fdac4a9c4468134ace9997090a7862a80df9de8634c6d1db0c9e956b91af5828760fd928eda3e725c101017ac794
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
package/index.d.ts CHANGED
@@ -9,7 +9,6 @@
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 {
15
14
  const device: Detox.DetoxExportWrapper['device'];
@@ -107,7 +106,7 @@ declare global {
107
106
  * @default 'sandbox'
108
107
  */
109
108
  overrideConsole?: 'all' | 'sandbox' | 'none';
110
- options?: BunyanDebugStreamOptions;
109
+ options?: BunyanDebugStreamOptions | ((config: Partial<DetoxLoggerConfig>) => BunyanDebugStreamOptions);
111
110
  }
112
111
 
113
112
  interface DetoxSessionConfig {
@@ -344,64 +343,74 @@ declare global {
344
343
  readonly log: Logger;
345
344
 
346
345
  /**
346
+ * @deprecated
347
+ *
348
+ * Deprecated - use {@link Detox.Logger#trace}
347
349
  * Detox tracer instance. Can be used for building timelines in Google Event Tracing format.
348
350
  */
349
- readonly trace: Tracer;
351
+ readonly trace: {
352
+ /** @deprecated */
353
+ readonly startSection: (name: string) => void;
354
+ /** @deprecated */
355
+ readonly endSection: (name: string) => void;
356
+ };
350
357
 
351
358
  /**
352
359
  * @deprecated
353
360
  */
354
- readonly traceCall: _TraceCallSignature;
361
+ readonly traceCall: <T>(event: string, action: () => Promise<T>) => Promise<T>;
355
362
  }
356
363
 
357
- /** @internal */
358
- type _TraceEventArgs = Record<string, unknown>;
364
+ interface Logger {
365
+ readonly level: DetoxLogLevel;
359
366
 
360
- type TraceEvent = {
361
- name?: string;
362
- cat?: string;
363
- cname?: string;
364
- id?: number;
365
- args?: _TraceEventArgs;
366
- };
367
+ readonly fatal: _LogMethod;
368
+ readonly error: _LogMethod;
369
+ readonly warn: _LogMethod;
370
+ readonly info: _LogMethod;
371
+ readonly debug: _LogMethod;
372
+ readonly trace: _LogMethod;
367
373
 
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>;
374
+ child(context?: Partial<LogEvent>): Logger;
376
375
  }
377
376
 
378
377
  /** @internal */
379
- interface _TraceSectionSignature<T> {
380
- (event?: string, args?: _TraceEventArgs): T;
381
- (event: TraceEvent): T;
378
+ interface _LogMethod extends _LogMethodSignature {
379
+ readonly begin: _LogMethodSignature;
380
+ readonly complete: _CompleteMethodSignature;
381
+ readonly end: _LogMethodSignature;
382
382
  }
383
383
 
384
- interface Tracer extends _TraceCallSignature {
385
- readonly begin: _TraceSectionSignature<EndHandle<{ cname: string; args: _TraceEventArgs; }>>;
386
- readonly end: _TraceSectionSignature<void>;
384
+ /** @internal */
385
+ interface _LogMethodSignature {
386
+ (...args: unknown[]): void
387
+ (event: LogEvent, ...args: unknown[]): void;
388
+ }
387
389
 
388
- /** @deprecated */
389
- readonly startSection: _TraceSectionSignature<void>;
390
- /** @deprecated */
391
- readonly endSection: _TraceSectionSignature<void>;
390
+ /** @internal */
391
+ interface _CompleteMethodSignature {
392
+ <T>(message: string, action: T | (() => T)): T;
393
+ <T>(event: LogEvent, message: string, action: T | (() => T)): T;
392
394
  }
393
395
 
394
- type Logger = {
395
- readonly level: DetoxLogLevel;
396
+ type LogEvent = {
397
+ /** Use when there's a risk of logging several parallel duration events. */
398
+ id?: string | number;
399
+ /** Optional. Event categories (tags) to facilitate filtering. */
400
+ cat?: string | string[];
401
+ /** Optional. Color name (applicable in Google Chrome Trace Format) */
402
+ cname?: string;
396
403
 
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;
404
+ /** Reserved property. Process ID. */
405
+ pid?: never;
406
+ /** Reserved property. Thread ID. */
407
+ tid?: never;
408
+ /** Reserved property. Timestamp. */
409
+ ts?: never;
410
+ /** Reserved property. Event phase. */
411
+ ph?: never;
403
412
 
404
- child(context?: Record<string, unknown>): Logger;
413
+ [customProperty: string]: unknown;
405
414
  };
406
415
 
407
416
  type DetoxLogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
package/internals.d.ts CHANGED
@@ -3,33 +3,40 @@
3
3
 
4
4
  declare global {
5
5
  namespace DetoxInternals {
6
+ type DetoxStatus = 'inactive' | 'init' | 'active' | 'cleanup';
7
+
6
8
  type Facade = {
7
9
  // region Initialization
8
10
  /**
9
- * Use with a caution, when you still have no config, yet need to avoid {@link Facade#globalSetup}
11
+ * Use with a caution, when you still have no config, yet need to avoid {@link Facade#init}
12
+ */
13
+ resolveConfig(options?: Partial<DetoxInitOptions>): Promise<RuntimeConfig>;
14
+
15
+ /**
16
+ *
10
17
  */
11
- resolveConfig(options?: Partial<DetoxGlobalSetupOptions>): Promise<RuntimeConfig>;
18
+ getStatus(): DetoxStatus;
12
19
 
13
20
  /**
14
21
  * This is the phase where Detox reads its configuration, starts a server.
15
22
  */
16
- globalSetup(options?: Partial<DetoxGlobalSetupOptions>): Promise<void>;
23
+ init(options?: Partial<DetoxInitOptions>): Promise<void>;
17
24
 
18
25
  /**
19
- * This is the phase where Detox loads its expection library and starts a device.
26
+ * This is the phase where Detox loads its expectation library and starts a device.
20
27
  */
21
- setup(options?: Partial<DetoxConfigurationSetupOptions>): Promise<void>;
28
+ installWorker(options?: Partial<DetoxInstallWorkerOptions>): Promise<void>;
22
29
 
23
30
  /**
24
- * The teardown phase deallocates the device.
31
+ * Deallocates the device.
25
32
  */
26
- teardown(): Promise<void>;
33
+ uninstallWorker(): Promise<void>;
27
34
 
28
35
  /**
29
36
  * The global cleanup phase should happen after all the tests have finished.
30
37
  * This is the phase where the Detox server shuts down.
31
38
  */
32
- globalTeardown(): Promise<void>;
39
+ cleanup(): Promise<void>;
33
40
  // endregion
34
41
 
35
42
  // region Lifecycle
@@ -59,45 +66,91 @@ declare global {
59
66
 
60
67
  readonly config: RuntimeConfig;
61
68
  readonly log: Detox.Logger;
62
- readonly trace: Detox.Tracer;
63
69
  readonly session: SessionState;
64
70
 
65
- readonly worker: unknown;
71
+ readonly worker: Worker;
72
+ }
73
+
74
+ interface Worker extends Detox.DetoxExportWrapper {
75
+ readonly id: string;
66
76
  }
67
77
 
68
- type DetoxGlobalSetupOptions = {
78
+ type DetoxInitOptions = {
69
79
  cwd: string;
70
80
  argv: Record<string, unknown>;
71
81
  testRunnerArgv: Record<string, unknown>;
72
82
  override: Partial<Detox.DetoxConfig>;
83
+ /** @inheritDoc */
84
+ global: NodeJS.Global;
85
+ /**
86
+ * Worker ID. Used to distinguish allocated workers in parallel test execution environment.
87
+ *
88
+ * If explicitly set to null, tells {@link Facade#init} to skip {@link Facade#installWorker} call.
89
+ * Useful for complex test runner integrations, where you have to install the worker via a separate call,
90
+ * when the environment is ready for that.
91
+ *
92
+ * @default 'worker'
93
+ */
94
+ workerId: string | null;
73
95
  };
74
96
 
75
- type DetoxConfigurationSetupOptions = {
97
+ type DetoxInstallWorkerOptions = {
98
+ /**
99
+ * Used for integration with sandboxed test environments.
100
+ * {@link DetoxInternals.Facade#setup} might override {@link Console} methods
101
+ * to integrate it with Detox loggeing subsystem.
102
+ */
76
103
  global: NodeJS.Global;
77
- workerId: number;
104
+ /**
105
+ * Worker ID. Used to distinguish allocated workers in parallel test execution environment.
106
+ *
107
+ * @default 'worker'
108
+ */
109
+ workerId: string;
78
110
  };
79
111
 
80
112
  type SessionState = Readonly<{
113
+ /**
114
+ * Randomly generated ID for the entire Detox test session, including retries.
115
+ */
116
+ id: string;
117
+ /**
118
+ * Permanently failed test file paths.
119
+ */
81
120
  failedTestFiles: string[];
121
+ /**
122
+ * Failed test file paths suggested to retry via Detox CLI mechanism.
123
+ */
82
124
  testFilesToRetry: string[];
125
+ /**
126
+ * Retry index of the test session: 0..retriesCount.
127
+ */
83
128
  testSessionIndex: number;
129
+ /**
130
+ * TODO
131
+ */
84
132
  workersCount: number;
85
133
  }>;
86
134
 
87
135
  type RuntimeConfig = Readonly<{
88
136
  configurationName: string;
89
137
 
90
- appsConfig: Record<string, Readonly<Detox.DetoxAppConfig>>;
91
- artifactsConfig: Detox.DetoxArtifactsConfig;
92
- behaviorConfig: Detox.DetoxBehaviorConfig;
93
- cliConfig: DetoxCLIConfig;
94
- deviceConfig: Detox.DetoxDeviceConfig;
95
- loggerConfig: Detox.DetoxLoggerConfig;
96
- runnerConfig: Detox.DetoxTestRunnerConfig;
97
- sessionConfig: Detox.DetoxSessionConfig;
138
+ /**
139
+ * Dictionary of app configurations,
140
+ * where the keys are defined by {@link Detox.DetoxAppConfig#name}
141
+ * or equal to "default" if the name is not configured.
142
+ */
143
+ apps: Record<string, Readonly<Detox.DetoxAppConfig>>;
144
+ artifacts: Readonly<Detox.DetoxArtifactsConfig>;
145
+ behavior: Readonly<Detox.DetoxBehaviorConfig>;
146
+ cli: Readonly<CLIConfig>;
147
+ device: Readonly<Detox.DetoxDeviceConfig>;
148
+ logger: Readonly<Detox.DetoxLoggerConfig>;
149
+ testRunner: Readonly<Detox.DetoxTestRunnerConfig>;
150
+ session: Readonly<Detox.DetoxSessionConfig>;
98
151
  }>;
99
152
 
100
- type DetoxCLIConfig = Readonly<Partial<{
153
+ type CLIConfig = Readonly<Partial<{
101
154
  appLaunchArgs: string;
102
155
  artifactsLocation: string;
103
156
  captureViewHierarchy: string;
@@ -37,7 +37,7 @@ module.exports.builder = {
37
37
  };
38
38
 
39
39
  module.exports.handler = async function build(argv) {
40
- const { appsConfig, errorComposer } = await detox.resolveConfig({ argv });
40
+ const { apps: appsConfig, errorComposer } = await detox.resolveConfig({ argv });
41
41
  const apps = _.entries(appsConfig);
42
42
 
43
43
  for (const [appName, app] of apps) {
@@ -14,12 +14,12 @@ describe('build', () => {
14
14
  const DetoxConfigErrorComposer = require('../src/errors/DetoxConfigErrorComposer');
15
15
 
16
16
  const config = {
17
- appsConfig: {},
18
- artifactsConfig: {},
19
- behaviorConfig: {},
17
+ apps: {},
18
+ artifacts: {},
19
+ behavior: {},
20
20
  errorComposer: new DetoxConfigErrorComposer(),
21
- deviceConfig: {},
22
- sessionConfig: {}
21
+ device: {},
22
+ session: {}
23
23
  };
24
24
 
25
25
  return ({
@@ -44,14 +44,14 @@ describe('build', () => {
44
44
  });
45
45
 
46
46
  it('runs the build script from the composed device config', async () => {
47
- detox.config.appsConfig.default = { build: 'yet another command' };
47
+ detox.config.apps.default = { build: 'yet another command' };
48
48
 
49
49
  await callCli('./build', 'build');
50
50
  expect(execSync).toHaveBeenCalledWith('yet another command', expect.anything());
51
51
  });
52
52
 
53
53
  it('skips building the app if the binary exists and --if-missing flag is set', async () => {
54
- detox.config.appsConfig.default = { build: 'yet another command', binaryPath: __filename };
54
+ detox.config.apps.default = { build: 'yet another command', binaryPath: __filename };
55
55
 
56
56
  await callCli('./build', 'build -i');
57
57
  expect(execSync).not.toHaveBeenCalled();
@@ -63,32 +63,32 @@ describe('build', () => {
63
63
  });
64
64
 
65
65
  it('fails with an error if a build script has not been found', async () => {
66
- detox.config.appsConfig.default = {};
66
+ detox.config.apps.default = {};
67
67
  await expect(callCli('./build', 'build')).rejects.toThrowError(/Failed to build/);
68
68
  });
69
69
 
70
70
  it('should ignore missing build command with -s, --silent flag', async () => {
71
- detox.config.appsConfig.default = {};
71
+ detox.config.apps.default = {};
72
72
  await expect(callCli('./build', 'build -s')).resolves.not.toThrowError();
73
73
  expect(detox.log.warn).not.toHaveBeenCalled();
74
74
  });
75
75
 
76
76
  it('should print a warning upon user build script failure', async () => {
77
- detox.config.appsConfig.default = { build: 'a command' };
77
+ detox.config.apps.default = { build: 'a command' };
78
78
  execSync.mockImplementation(() => { throw new Error('Build failure'); });
79
79
  await expect(callCli('./build', 'build')).rejects.toThrowError(/Build failure/);
80
80
  expect(detox.log.warn).toHaveBeenCalledWith(expect.stringContaining('You are responsible'));
81
81
  });
82
82
 
83
83
  it('should print a warning if app is not found at binary path', async () => {
84
- detox.config.appsConfig.default = { binaryPath: tempfile() };
84
+ detox.config.apps.default = { binaryPath: tempfile() };
85
85
  await expect(callCli('./build', 'build -s')).resolves.not.toThrowError();
86
86
  expect(detox.log.warn).toHaveBeenCalledWith(expect.stringContaining('could not find your app at the given binary path'));
87
87
  });
88
88
 
89
89
  it('should print extra message with the app name before building (in a multi-app configuration)', async () => {
90
- detox.config.appsConfig.app1 = { binaryPath: tempfile(), build: ':' };
91
- detox.config.appsConfig.app2 = { binaryPath: tempfile(), build: ':' };
90
+ detox.config.apps.app1 = { binaryPath: tempfile(), build: ':' };
91
+ detox.config.apps.app2 = { binaryPath: tempfile(), build: ':' };
92
92
 
93
93
  await expect(callCli('./build', 'build -s')).resolves.not.toThrowError();
94
94
  expect(detox.log.info).toHaveBeenCalledWith(expect.stringContaining('app1'));
@@ -96,7 +96,7 @@ describe('build', () => {
96
96
  });
97
97
 
98
98
  it('should not print that extra message when the app is single', async () => {
99
- detox.config.appsConfig.default = { binaryPath: tempfile(), build: ':' };
99
+ detox.config.apps.default = { binaryPath: tempfile(), build: ':' };
100
100
 
101
101
  await expect(callCli('./build', 'build -s')).resolves.not.toThrowError();
102
102
  expect(detox.log.info).not.toHaveBeenCalledWith(expect.stringContaining('default'));
package/local-cli/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  const yargs = require('yargs');
3
3
 
4
4
  const DetoxError = require('../src/errors/DetoxError');
5
- const logger = require('../src/utils/logger').child({ __filename });
5
+ const logger = require('../src/utils/logger').child({ cat: 'cli' });
6
6
 
7
7
  yargs
8
8
  .scriptName('detox')
@@ -4,7 +4,7 @@ const path = require('path');
4
4
 
5
5
  const fs = require('fs-extra');
6
6
 
7
- const log = require('../src/utils/logger').child({ __filename });
7
+ const log = require('../src/utils/logger').child({ cat: 'cli' });
8
8
 
9
9
  module.exports.command = 'rebuild-framework-cache';
10
10
  module.exports.desc = 'Rebuilds a cached Detox framework for the current environment in ~/Library/Detox. The cached framework is unique for each combination of Xcode and Detox version. (macOS only)';
package/local-cli/test.js CHANGED
@@ -9,18 +9,19 @@ module.exports.middlewares = require('./testCommand/middlewares').default;
9
9
 
10
10
  module.exports.handler = async function test({ detoxArgs, runnerArgs }) {
11
11
  try {
12
- await detox.globalSetup({
12
+ await detox.init({
13
13
  argv: detoxArgs,
14
14
  testRunnerArgv: runnerArgs,
15
+ workerId: null,
15
16
  });
16
17
 
17
18
  const runnerCommand = new TestRunnerCommand()
18
- .setRunnerConfig(detox.config.runnerConfig)
19
- .setDeviceConfig(detox.config.deviceConfig)
20
- .replicateCLIConfig(detox.config.cliConfig);
19
+ .setRunnerConfig(detox.config.testRunner)
20
+ .setDeviceConfig(detox.config.device)
21
+ .replicateCLIConfig(detox.config.cli);
21
22
 
22
23
  await runnerCommand.execute();
23
24
  } finally {
24
- await detox.globalTeardown();
25
+ await detox.cleanup();
25
26
  }
26
27
  };
@@ -116,7 +116,7 @@ describe('CLI', () => {
116
116
  });
117
117
  });
118
118
 
119
- test('should use runnerConfig.specs as default specs', async () => {
119
+ test('should use testRunner.args._ as default specs', async () => {
120
120
  detoxConfig.testRunner.args._ = ['e2e/sanity'];
121
121
  await run();
122
122
  expect(_.last(cliCall().argv)).toEqual('e2e/sanity');
@@ -504,7 +504,7 @@ describe('CLI', () => {
504
504
  return {
505
505
  ...mockCall,
506
506
  fullCommand: _.chain(logger().log.mock.calls)
507
- .filter(([_level, _childMeta, meta]) => meta && meta.event === 'RUN_START')
507
+ .filter(([_level, _childMeta, meta]) => meta && meta.env)
508
508
  .get(index)
509
509
  .get(3)
510
510
  .value(),
@@ -5,6 +5,7 @@ const parser = require('yargs-parser');
5
5
  const unparse = require('yargs-unparser');
6
6
 
7
7
  const detox = require('../../internals');
8
+ const log = detox.log.child({ cat: ['lifecycle', 'cli'] });
8
9
  const { DetoxRuntimeError } = require('../../src/errors');
9
10
  const { printEnvironmentVariables, prependNodeModulesBinToPATH } = require('../../src/utils/envUtils');
10
11
  const { escapeSpaces } = require('../../src/utils/shellUtils');
@@ -45,7 +46,7 @@ class TestRunnerCommand {
45
46
  }
46
47
 
47
48
  /**
48
- * @param {Partial<Readonly<DetoxInternals.DetoxCLIConfig>>} cliConfig
49
+ * @param {Partial<Readonly<DetoxInternals.CLIConfig>>} cliConfig
49
50
  * @returns {this}
50
51
  */
51
52
  replicateCLIConfig(cliConfig) {
@@ -88,7 +89,7 @@ class TestRunnerCommand {
88
89
  try {
89
90
  if (launchError) {
90
91
  const list = this._argv._.map((file, index) => ` ${index + 1}. ${file}`).join('\n');
91
- detox.log.error({ event: 'RETRY_RUN' },
92
+ log.error(
92
93
  `There were failing tests in the following files:\n${list}\n\n` +
93
94
  'Detox CLI is going to restart the test runner with those files...\n'
94
95
  );
@@ -119,7 +120,7 @@ class TestRunnerCommand {
119
120
  const fullCommand = this._buildSpawnArguments().map(escapeSpaces);
120
121
  const fullCommandWithHint = printEnvironmentVariables(this._envHint) + fullCommand.join(' ');
121
122
 
122
- detox.log.info({ event: 'RUN_START', env: this._envHint }, fullCommandWithHint);
123
+ log.info({ env: this._envHint }, fullCommandWithHint);
123
124
 
124
125
  return new Promise((resolve, reject) => {
125
126
  cp.spawn(fullCommand[0], fullCommand.slice(1), {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "detox",
3
3
  "description": "E2E tests and automation for mobile",
4
- "version": "20.0.2-breaking.new-global-lifecycle.0",
4
+ "version": "20.0.5-breaking.new-global-lifecycle.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -57,13 +57,14 @@
57
57
  "dependencies": {
58
58
  "ajv": "^8.6.3",
59
59
  "bunyan": "^1.8.12",
60
- "bunyan-debug-stream": "^3.0.2",
60
+ "bunyan-debug-stream": "^3.1.0",
61
61
  "chalk": "^2.4.2",
62
62
  "child-process-promise": "^2.2.0",
63
63
  "duplexify": "^4.1.2",
64
64
  "find-up": "^4.1.0",
65
65
  "fs-extra": "^4.0.2",
66
66
  "funpermaproxy": "^1.0.1",
67
+ "glob": "^8.0.3",
67
68
  "ini": "^1.3.4",
68
69
  "json-cycle": "^1.3.0",
69
70
  "lodash": "^4.17.5",
@@ -83,7 +84,7 @@
83
84
  "tail": "^2.0.0",
84
85
  "telnet-client": "1.2.8",
85
86
  "tempfile": "^2.0.0",
86
- "trace-event-lib": "^1.1.0",
87
+ "trace-event-lib": "^1.3.1",
87
88
  "which": "^1.3.1",
88
89
  "ws": "^7.0.0",
89
90
  "yargs": "^16.0.3",
@@ -183,5 +184,5 @@
183
184
  }
184
185
  }
185
186
  },
186
- "gitHead": "cda5a555ec90aaeafe8c557157270e36a2b27688"
187
+ "gitHead": "e299576e350a493084cf00a3007e5dd1ae03c3d5"
187
188
  }
@@ -1 +1 @@
1
- module.exports = async () => require('../../internals').globalSetup();
1
+ module.exports = async () => require('../../internals').init({ workerId: null });
@@ -1 +1 @@
1
- module.exports = async () => require('../../internals').globalTeardown();
1
+ module.exports = async () => require('../../internals').cleanup();