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
@@ -7,25 +7,34 @@ const { castLevel, defaultOptions } = require('../logger/DetoxLogger');
7
7
  * @param {Detox.DetoxConfig} opts.globalConfig
8
8
  * @param {Detox.DetoxConfiguration} opts.localConfig
9
9
  * @param {*} opts.cliConfig
10
- * @returns {Detox.DetoxLoggerConfig}
11
10
  */
12
11
  function composeLoggerConfig(opts) {
13
12
  const { globalConfig, localConfig, cliConfig } = opts;
14
13
 
15
- return _.merge(
14
+ const items = [
16
15
  {
17
16
  level: 'info',
18
17
  overrideConsole: 'sandbox',
19
- options: {
20
- ...defaultOptions,
21
- prefixers: {
22
- ...defaultOptions.prefixers,
23
- },
24
- },
18
+ options: defaultOptions,
25
19
  },
26
20
  globalConfig.logger,
27
21
  localConfig.logger,
28
22
  adaptCLI(cliConfig),
23
+ ];
24
+
25
+ return items.reduce(
26
+ /**
27
+ * @param {Partial<Detox.DetoxLoggerConfig>} acc
28
+ * @param config
29
+ */
30
+ (acc, config) => {
31
+ if (!config) return acc;
32
+ const { options } = config;
33
+ return _.merge(acc, {
34
+ options: typeof options === 'function' ? options(acc) : options
35
+ });
36
+ },
37
+ items.reduce((a, b) => _.merge(a, _.omit(b, 'options')))
29
38
  );
30
39
  }
31
40
 
@@ -2,17 +2,19 @@ const os = require('os');
2
2
 
3
3
  const _ = require('lodash');
4
4
 
5
+ const log = require('../utils/logger');
6
+
5
7
  /**
6
8
  * @param {object} opts
7
9
  * @param {Detox.DetoxConfig} opts.globalConfig
8
10
  * @param {Detox.DetoxConfiguration} opts.localConfig
9
- * @param {DetoxInternals.DetoxCLIConfig} opts.cliConfig
11
+ * @param {DetoxInternals.CLIConfig} opts.cliConfig
10
12
  * @param {Record<string, any>} opts.testRunnerArgv
11
13
  * @param {import('../errors/DetoxConfigErrorComposer')} opts.errorComposer
12
14
  * @returns {Detox.DetoxTestRunnerConfig} opts.testRunnerArgv
13
15
  */
14
16
  function composeRunnerConfig(opts) {
15
- const globalConfig = opts.globalConfig.testRunner;
17
+ const globalConfig = adaptLegacyRunnerConfig(opts.globalConfig);
16
18
  if (globalConfig != null && typeof globalConfig !== 'object') {
17
19
  throw opts.errorComposer.invalidTestRunnerProperty(true);
18
20
  }
@@ -61,6 +63,51 @@ function composeRunnerConfig(opts) {
61
63
  return merged;
62
64
  }
63
65
 
66
+ function adaptLegacyRunnerConfig(globalConfig) {
67
+ let isLegacy = false;
68
+
69
+ const runnerConfigKey = 'runnerConfig' in globalConfig ? 'runnerConfig' : 'runner-config';
70
+ if (_.isString(globalConfig[runnerConfigKey])) {
71
+ isLegacy = true;
72
+ log.warn(`Detected a deprecated "${runnerConfigKey}" property (string).`);
73
+ }
74
+
75
+ const testRunnerKey = 'testRunner' in globalConfig ? 'testRunner' : 'test-runner';
76
+ if (_.isString(globalConfig[testRunnerKey])) {
77
+ isLegacy = true;
78
+ log.warn(`Detected a deprecated "${testRunnerKey}" property (string).`);
79
+ }
80
+
81
+ if (globalConfig.specs != null) {
82
+ isLegacy = true;
83
+ log.warn(`Detected a deprecated "specs" property.`);
84
+ }
85
+
86
+ if (!isLegacy) {
87
+ return globalConfig.testRunner;
88
+ }
89
+
90
+ log.warn(`Please migrate your Detox config according to the guide: [TODO: insert the migration guilde link]`);
91
+ const testRunner = globalConfig[testRunnerKey];
92
+ const runnerConfig = globalConfig[runnerConfigKey];
93
+ const specs = globalConfig.specs != null ? String(globalConfig.specs) : undefined;
94
+
95
+ const args = {};
96
+ if (_.isString(testRunner)) {
97
+ args.$0 = testRunner;
98
+ }
99
+
100
+ if (_.isString(runnerConfig)) {
101
+ args.config = runnerConfig;
102
+ }
103
+
104
+ if (specs) {
105
+ args._ = [specs];
106
+ }
107
+
108
+ return { args };
109
+ }
110
+
64
111
  function hasEmptyPositionalArgs(value, key) {
65
112
  return key === '_' ? _.isEmpty(value) : false;
66
113
  }
@@ -105,18 +105,23 @@ async function composeDetoxConfig({
105
105
  });
106
106
 
107
107
  const result = {
108
- appsConfig,
109
- artifactsConfig,
110
- behaviorConfig,
111
- cliConfig,
112
108
  configurationName,
113
- deviceConfig,
114
- errorComposer,
115
- loggerConfig,
116
- runnerConfig,
117
- sessionConfig,
109
+
110
+ apps: appsConfig,
111
+ artifacts: artifactsConfig,
112
+ behavior: behaviorConfig,
113
+ cli: cliConfig,
114
+ device: deviceConfig,
115
+ logger: loggerConfig,
116
+ testRunner: runnerConfig,
117
+ session: sessionConfig,
118
118
  };
119
119
 
120
+ Object.defineProperty(result, 'errorComposer', {
121
+ enumerable: false,
122
+ value: errorComposer,
123
+ });
124
+
120
125
  return result;
121
126
  }
122
127
 
@@ -6,7 +6,7 @@ const fs = require('fs-extra');
6
6
  const _ = require('lodash');
7
7
  const resolveFrom = require('resolve-from');
8
8
 
9
- const log = require('../utils/logger').child({ __filename });
9
+ const log = require('../utils/logger').child({ cat: 'config' });
10
10
 
11
11
  async function locateExternalConfig(cwd) {
12
12
  return findUp([
@@ -1,5 +1,6 @@
1
1
  // @ts-nocheck
2
- const { traceMethods } = require('../../utils/trace');
2
+ const log = require('../../utils/logger').child({ cat: 'device' });
3
+ const traceMethods = require('../../utils/traceMethods');
3
4
 
4
5
  class DeviceAllocator {
5
6
  /**
@@ -7,7 +8,7 @@ class DeviceAllocator {
7
8
  */
8
9
  constructor(allocationDriver) {
9
10
  this._driver = allocationDriver;
10
- traceMethods(this, 'device', ['allocate', 'free']);
11
+ traceMethods(log, this, ['allocate', 'free']);
11
12
  }
12
13
 
13
14
  /**
@@ -2,7 +2,7 @@ const _ = require('lodash');
2
2
 
3
3
  const DetoxRuntimeError = require('../../../../../errors/DetoxRuntimeError');
4
4
  const environment = require('../../../../../utils/environment');
5
- const logger = require('../../../../../utils/logger').child({ __filename });
5
+ const logger = require('../../../../../utils/logger').child({ cat: 'device' });
6
6
 
7
7
  const REQUIRED_EMULATOR_MAJOR = 29;
8
8
 
@@ -1,7 +1,8 @@
1
1
  // @ts-nocheck
2
2
  const _ = require('lodash');
3
3
 
4
- const { traceMethods } = require('../../../../../utils/trace');
4
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
5
+ const traceMethods = require('../../../../../utils/traceMethods');
5
6
  const AndroidEmulatorCookie = require('../../../../cookies/AndroidEmulatorCookie');
6
7
  const AllocationDriverBase = require('../../AllocationDriverBase');
7
8
 
@@ -23,7 +24,7 @@ class EmulatorAllocDriver extends AllocationDriverBase {
23
24
  this._emulatorLauncher = emulatorLauncher;
24
25
  this._allocationHelper = allocationHelper;
25
26
 
26
- traceMethods(this, 'device', ['_launchEmulator']);
27
+ traceMethods(log, this, ['_launchEmulator']);
27
28
  }
28
29
 
29
30
  /**
@@ -1,4 +1,4 @@
1
- const logger = require('../../../../../utils/logger').child({ __filename });
1
+ const logger = require('../../../../../utils/logger').child({ cat: 'device' });
2
2
  const DeviceAllocationHelper = require('../../../../common/drivers/DeviceAllocationHelper');
3
3
 
4
4
  const DetoxEmulatorsPortRange = {
@@ -1,7 +1,8 @@
1
1
  // @ts-nocheck
2
2
  const { DetoxRuntimeError } = require('../../../../../errors');
3
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
3
4
  const retry = require('../../../../../utils/retry');
4
- const { traceMethods } = require('../../../../../utils/trace');
5
+ const traceMethods = require('../../../../../utils/traceMethods');
5
6
  const DeviceLauncher = require('../../../../common/drivers/DeviceLauncher');
6
7
  const { LaunchCommand } = require('../../../../common/drivers/android/emulator/exec/EmulatorExec');
7
8
 
@@ -14,7 +15,7 @@ class EmulatorLauncher extends DeviceLauncher {
14
15
  super(eventEmitter);
15
16
  this._adb = adb;
16
17
  this._emulatorExec = emulatorExec;
17
- traceMethods(this, 'device', ['_awaitEmulatorBoot']);
18
+ traceMethods(log, this, ['_awaitEmulatorBoot']);
18
19
  }
19
20
 
20
21
  /**
@@ -1,8 +1,6 @@
1
- const log = require('../../../../../utils/logger').child({ __filename });
1
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
2
2
  const { QueryVersionCommand } = require('../../../../common/drivers/android/emulator/exec/EmulatorExec');
3
3
 
4
- const EMU_BIN_VERSION_DETECT_EV = 'EMU_BIN_VERSION_DETECT';
5
-
6
4
  class EmulatorVersionResolver {
7
5
  constructor(emulatorExec) {
8
6
  this._emulatorExec = emulatorExec;
@@ -21,18 +19,18 @@ class EmulatorVersionResolver {
21
19
  try {
22
20
  rawOutput = await this._emulatorExec.exec(new QueryVersionCommand({ headless })) || '';
23
21
  } catch (error) {
24
- log.error({ event: EMU_BIN_VERSION_DETECT_EV, success: false, error }, 'Could not detect emulator binary version', error);
22
+ log.error({ success: false, error }, 'Could not detect emulator binary version', error);
25
23
  return null;
26
24
  }
27
25
 
28
26
  const matches = rawOutput.match(/Android emulator version ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]*)/);
29
27
  if (!matches) {
30
- log.warn({ event: EMU_BIN_VERSION_DETECT_EV, success: false }, 'Could not detect emulator binary version, got:', rawOutput);
28
+ log.warn({ success: false }, 'Could not detect emulator binary version, got:', rawOutput);
31
29
  return null;
32
30
  }
33
31
 
34
32
  const version = this._parseVersionString(matches[1]);
35
- log.debug({ event: EMU_BIN_VERSION_DETECT_EV, success: true }, 'Detected emulator binary version', version);
33
+ log.debug({ success: true }, 'Detected emulator binary version', version);
36
34
  return version;
37
35
  }
38
36
 
@@ -3,7 +3,7 @@ const fs = require('fs');
3
3
  const _ = require('lodash');
4
4
  const { Tail } = require('tail');
5
5
 
6
- const unitLogger = require('../../../../../utils/logger').child({ __filename });
6
+ const unitLogger = require('../../../../../utils/logger').child({ cat: 'device' });
7
7
 
8
8
  function launchEmulatorProcess(emulatorName, emulatorExec, emulatorLaunchCommand) {
9
9
  let childProcessOutput;
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- const logger = require('../../../../../utils/logger').child({ __filename });
2
+ const logger = require('../../../../../utils/logger').child({ cat: 'device' });
3
3
  const DeviceAllocationHelper = require('../../../../common/drivers/DeviceAllocationHelper');
4
4
 
5
5
  const { ALLOCATE_DEVICE_LOG_EVT } = DeviceAllocationHelper;
@@ -1,9 +1,9 @@
1
- const session = () => require('../../../../../../../internals').session;
1
+ const internals = () => require('../../../../../../../internals');
2
2
 
3
3
  class GenyInstanceNaming {
4
4
  generateName() {
5
- const { id, workerId } = session();
6
- return `Detox.${id}.${workerId}`;
5
+ const { session, worker } = internals();
6
+ return `Detox.${session.id}.${worker.id}`;
7
7
  }
8
8
 
9
9
  isFamilial(name) {
@@ -1,4 +1,4 @@
1
- const logger = require('../../../../../../utils/logger').child({ __filename });
1
+ const logger = require('../../../../../../utils/logger').child({ cat: 'device' });
2
2
 
3
3
  const Recipe = require('./dto/GenyRecipe');
4
4
 
@@ -5,7 +5,7 @@ const path = require('path');
5
5
  const fs = require('fs-extra');
6
6
  const Telnet = require('telnet-client');
7
7
 
8
- const log = require('../../../../../utils/logger').child({ __filename });
8
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
9
9
 
10
10
  class EmulatorTelnet {
11
11
  constructor() {
@@ -1,4 +1,4 @@
1
- const log = require('../../../../../utils/logger').child({ __filename });
1
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
2
2
 
3
3
  const DEVICE_LOOKUP_LOG_EVT = 'DEVICE_LOOKUP';
4
4
 
@@ -7,7 +7,7 @@ const DetoxRuntimeError = require('../../../../../errors/DetoxRuntimeError');
7
7
  const { joinArgs } = require('../../../../../utils/argparse');
8
8
  const childProcess = require('../../../../../utils/childProcess');
9
9
  const environment = require('../../../../../utils/environment');
10
- const log = require('../../../../../utils/logger').child({ __filename });
10
+ const log = require('../../../../../utils/logger').child({ cat: 'device' });
11
11
  const { quote } = require('../../../../../utils/shellQuote');
12
12
 
13
13
  class AppleSimUtils {
@@ -1,6 +1,4 @@
1
- const onSignalExit = require('signal-exit');
2
-
3
- const logger = require('../../utils/logger').child({ __filename });
1
+ const logger = require('../../utils/logger').child({ cat: 'device' });
4
2
 
5
3
  const cleanupLogData = {
6
4
  event: 'GENYCLOUD_TEARDOWN',
@@ -12,16 +10,14 @@ class GenyGlobalLifecycleHandler {
12
10
  this._instanceLifecycleService = instanceLifecycleService;
13
11
  }
14
12
 
15
- async globalInit() {
16
- onSignalExit((code, signal) => {
17
- if (signal) {
18
- const { rawDevices } = this._deviceCleanupRegistry.readRegisteredDevicesUNSAFE();
19
- const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
20
- if (instanceHandles.length) {
21
- reportGlobalCleanupSummary(instanceHandles);
22
- }
23
- }
24
- });
13
+ async globalInit() {}
14
+
15
+ emergencyCleanup() {
16
+ const { rawDevices } = this._deviceCleanupRegistry.readRegisteredDevicesUNSAFE();
17
+ const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
18
+ if (instanceHandles.length) {
19
+ reportGlobalCleanupSummary(instanceHandles);
20
+ }
25
21
  }
26
22
 
27
23
  async globalCleanup() {
@@ -1,6 +1,8 @@
1
1
  const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
2
2
  const debug = require('../../utils/debug'); // debug utils, leave here even if unused
3
- const { traceCall, traceMethods } = require('../../utils/trace');
3
+ const log = require('../../utils/logger').child({ cat: 'device' });
4
+ const { traceCall } = require('../../utils/trace');
5
+ const traceMethods = require('../../utils/traceMethods');
4
6
  const wrapWithStackTraceCutter = require('../../utils/wrapWithStackTraceCutter');
5
7
 
6
8
  const LaunchArgsEditor = require('./utils/LaunchArgsEditor');
@@ -48,7 +50,7 @@ class RuntimeDevice {
48
50
  'unreverseTcpPort',
49
51
  ];
50
52
 
51
- traceMethods(this, 'device', methodNames);
53
+ traceMethods(log, this, methodNames);
52
54
  wrapWithStackTraceCutter(this, methodNames);
53
55
 
54
56
  this._appsConfig = appsConfig;
@@ -234,16 +236,13 @@ class RuntimeDevice {
234
236
  }
235
237
 
236
238
  async installApp(binaryPath, testBinaryPath) {
237
- await traceCall('appInstall', () => {
238
- const currentApp = binaryPath ? { binaryPath, testBinaryPath } : this._getCurrentApp();
239
- return this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath);
240
- });
239
+ const currentApp = binaryPath ? { binaryPath, testBinaryPath } : this._getCurrentApp();
240
+ await this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath);
241
241
  }
242
242
 
243
243
  async uninstallApp(bundleId) {
244
244
  const _bundleId = bundleId || this._bundleId;
245
- await traceCall('appUninstall', () =>
246
- this.deviceDriver.uninstallApp(_bundleId));
245
+ await this.deviceDriver.uninstallApp(_bundleId);
247
246
  }
248
247
 
249
248
  async installUtilBinaries() {
@@ -4,7 +4,7 @@ const path = require('path');
4
4
 
5
5
  const fs = require('fs-extra');
6
6
 
7
- const log = require('../../../utils/logger').child({ __filename });
7
+ const log = require('../../../utils/logger').child({ cat: 'device' });
8
8
 
9
9
  /**
10
10
  * @typedef DeviceDriverDeps
@@ -18,7 +18,7 @@ const sleep = require('../../../../utils/sleep');
18
18
  const apkUtils = require('../../../common/drivers/android/tools/apk');
19
19
  const DeviceDriverBase = require('../DeviceDriverBase');
20
20
 
21
- const log = logger.child({ __filename });
21
+ const log = logger.child({ cat: 'device' });
22
22
 
23
23
  /**
24
24
  * @typedef AndroidDriverProps
@@ -7,7 +7,7 @@ const _ = require('lodash');
7
7
  const temporaryPath = require('../../../../artifacts/utils/temporaryPath');
8
8
  const DetoxRuntimeError = require('../../../../errors/DetoxRuntimeError');
9
9
  const getAbsoluteBinaryPath = require('../../../../utils/getAbsoluteBinaryPath');
10
- const log = require('../../../../utils/logger').child({ __filename });
10
+ const log = require('../../../../utils/logger').child({ cat: 'device' });
11
11
  const pressAnyKey = require('../../../../utils/pressAnyKey');
12
12
 
13
13
  const IosDriver = require('./IosDriver');
@@ -656,12 +656,14 @@ Examine your Detox config${this._atPath()}`,
656
656
  }
657
657
 
658
658
  invalidTestRunnerProperty(isGlobal) {
659
+ const testRunner = _.get(this.contents, ['testRunner']);
660
+
659
661
  return new DetoxConfigError({
660
- message: `testRunner should be an object, not a string`,
662
+ message: `testRunner should be an object, not a ${typeof testRunner}`,
661
663
  hint: `Check that in your Detox config${this._atPath()}`,
662
664
  inspectOptions: { depth: isGlobal ? 0 : 3 },
663
665
  debugInfo: isGlobal ? {
664
- testRunner: _.get(this.contents, ['testRunner']),
666
+ testRunner,
665
667
  ...this.contents,
666
668
  } : {
667
669
  ...this._focusOnConfiguration(c => _.pick(c, ['testRunner'])),
@@ -6,8 +6,8 @@ class IPCClient {
6
6
  constructor({ id, logger, state }) {
7
7
  this._id = id;
8
8
  /** @type {import('../logger/DetoxLogger')} logger */
9
- this._logger = logger.child({ __filename, cat: 'ipc' });
10
- /** @type {import('./state').SecondarySessionState} */
9
+ this._logger = logger.child({ cat: 'ipc' });
10
+ /** @type {import('./SessionState')} */
11
11
  this._state = state;
12
12
 
13
13
  this._client = null;
@@ -47,7 +47,6 @@ class IPCClient {
47
47
  }
48
48
 
49
49
  async registerWorker(workerId) {
50
- this._state.workerId = workerId;
51
50
  await this._emit('registerWorker', { workerId });
52
51
  }
53
52
 
@@ -75,11 +74,7 @@ class IPCClient {
75
74
  }
76
75
 
77
76
  async _registerContext() {
78
- const sessionState = await this._emit('registerContext', {
79
- id: this._id,
80
- logFile: this._logger.file,
81
- });
82
-
77
+ const sessionState = await this._emit('registerContext', { id: this._id });
83
78
  this._state.patch(sessionState);
84
79
  }
85
80
 
@@ -3,13 +3,14 @@ const { IPC } = require('node-ipc');
3
3
  class IPCServer {
4
4
  /**
5
5
  * @param {object} options
6
- * @param {import('./state').PrimarySessionState} options.sessionState
6
+ * @param {import('./SessionState')} options.sessionState
7
7
  * @param {Detox.Logger} options.logger
8
8
  */
9
9
  constructor({ sessionState, logger }) {
10
10
  this._sessionState = sessionState;
11
- this._logger = logger.child({ __filename, cat: 'ipc' });
11
+ this._logger = logger.child({ cat: 'ipc,ipc-server' });
12
12
  this._ipc = null;
13
+ this._workers = new Set();
13
14
  }
14
15
 
15
16
  get id() {
@@ -48,13 +49,9 @@ class IPCServer {
48
49
  });
49
50
  }
50
51
 
51
- onRegisterContext({ id, logFile }, socket) {
52
+ onRegisterContext({ id }, socket) {
52
53
  this._sessionState.contexts.push(id);
53
54
 
54
- if (logFile && !this._sessionState.logFiles.includes(logFile)) {
55
- this._sessionState.logFiles.push(logFile);
56
- }
57
-
58
55
  this._ipc.server.emit(socket, 'registerContextDone', {
59
56
  failedTestFiles: this._sessionState.failedTestFiles,
60
57
  testFilesToRetry: this._sessionState.testFilesToRetry,
@@ -62,13 +59,16 @@ class IPCServer {
62
59
  });
63
60
  }
64
61
 
65
- onRegisterWorker({ workerId }, socket) {
62
+ onRegisterWorker({ workerId }, socket = null) {
63
+ const workersCount = this._workers.add(workerId).size;
64
+ const shouldBroadcast = workersCount > this._sessionState.workersCount;
65
+ this._sessionState.workersCount = workersCount;
66
+
66
67
  if (socket) {
67
- this._ipc.server.emit(socket, 'registerWorkerDone', {});
68
+ this._ipc.server.emit(socket, 'registerWorkerDone', { workersCount });
68
69
  }
69
70
 
70
- if (workerId > this._sessionState.workersCount) {
71
- const workersCount = this._sessionState.workersCount = workerId;
71
+ if (shouldBroadcast) {
72
72
  this._ipc.server.broadcast('sessionStateUpdate', { workersCount });
73
73
  }
74
74
  }
@@ -3,6 +3,28 @@ const cycle = require('json-cycle');
3
3
  const uuid = require('../utils/uuid');
4
4
 
5
5
  class SessionState {
6
+ constructor({
7
+ id = uuid.UUID(),
8
+ contexts = [],
9
+ detoxConfigSnapshotPath = '',
10
+ detoxConfig = null,
11
+ detoxIPCServer = '',
12
+ failedTestFiles = [],
13
+ testFilesToRetry = [],
14
+ testSessionIndex = 0,
15
+ workersCount = 0
16
+ }) {
17
+ this.id = id;
18
+ this.contexts = contexts;
19
+ this.detoxConfigSnapshotPath = detoxConfigSnapshotPath;
20
+ this.detoxConfig = detoxConfig;
21
+ this.detoxIPCServer = detoxIPCServer;
22
+ this.failedTestFiles = failedTestFiles;
23
+ this.testFilesToRetry = testFilesToRetry;
24
+ this.testSessionIndex = testSessionIndex;
25
+ this.workersCount = workersCount;
26
+ }
27
+
6
28
  patch(state) {
7
29
  Object.assign(this, state);
8
30
  }
@@ -37,53 +59,4 @@ class SessionState {
37
59
  }
38
60
  }
39
61
 
40
- class SecondarySessionState extends SessionState {
41
- constructor({
42
- id = uuid.UUID(),
43
- detoxConfigSnapshotPath = '',
44
- detoxConfig = null,
45
- detoxIPCServer = '',
46
- failedTestFiles = [],
47
- testFilesToRetry = [],
48
- testSessionIndex = 0,
49
- workerId = undefined,
50
- workersCount = 0
51
- }) {
52
- super();
53
-
54
- this.id = id;
55
- this.detoxConfigSnapshotPath = detoxConfigSnapshotPath;
56
- this.detoxConfig = detoxConfig;
57
- this.detoxIPCServer = detoxIPCServer;
58
- this.failedTestFiles = failedTestFiles;
59
- this.testFilesToRetry = testFilesToRetry;
60
- this.testSessionIndex = testSessionIndex;
61
- this.workerId = workerId;
62
- this.workersCount = workersCount;
63
- }
64
- }
65
-
66
- class PrimarySessionState extends SecondarySessionState {
67
- constructor({
68
- contexts = [],
69
- logFiles = [],
70
- failedTestFiles = [],
71
- testFilesToRetry = [],
72
- testSessionIndex = 0,
73
- ...baseOpts
74
- }) {
75
- super(baseOpts);
76
-
77
- this.contexts = contexts;
78
- this.failedTestFiles = failedTestFiles;
79
- this.logFiles = logFiles;
80
- this.testSessionIndex = testSessionIndex;
81
- this.testFilesToRetry = testFilesToRetry;
82
- }
83
- }
84
-
85
- module.exports = {
86
- SessionState,
87
- PrimarySessionState,
88
- SecondarySessionState,
89
- };
62
+ module.exports = SessionState;