detox 19.13.0 → 20.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0-javadoc.jar → 20.0.0/detox-20.0.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0-sources.jar → 20.0.0/detox-20.0.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0.pom → 20.0.0/detox-20.0.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.0/detox-20.0.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/README.md +1 -1
  29. package/android/detox/src/full/java/com/wix/detox/Detox.java +2 -59
  30. package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
  31. package/index.d.ts +354 -191
  32. package/index.js +1 -0
  33. package/internals.d.ts +298 -0
  34. package/internals.js +4 -0
  35. package/local-cli/build-framework-cache.js +2 -2
  36. package/local-cli/build.js +7 -8
  37. package/local-cli/build.test.js +46 -40
  38. package/local-cli/clean-framework-cache.js +3 -3
  39. package/local-cli/cli.js +8 -7
  40. package/local-cli/init.js +73 -68
  41. package/local-cli/rebuild-framework-cache.js +1 -1
  42. package/local-cli/reset-lock-file.js +16 -0
  43. package/local-cli/templates/jest.js +14 -36
  44. package/local-cli/test.js +24 -282
  45. package/local-cli/test.test.js +394 -648
  46. package/local-cli/testCommand/TestRunnerCommand.js +163 -0
  47. package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -36
  48. package/local-cli/testCommand/middlewares.js +66 -0
  49. package/local-cli/{utils → testCommand}/warnings.js +0 -13
  50. package/local-cli/utils/jestInternals.js +13 -2
  51. package/local-cli/utils/yargsUtils.js +67 -0
  52. package/package.json +32 -19
  53. package/runners/deprecation.js +45 -0
  54. package/runners/jest/JestCircusEnvironment.js +3 -38
  55. package/runners/jest/adapter.d.ts +4 -10
  56. package/runners/jest/adapter.js +3 -6
  57. package/runners/jest/assignReporter.d.ts +4 -1
  58. package/runners/jest/assignReporter.js +3 -6
  59. package/runners/jest/globalSetup.js +1 -0
  60. package/runners/jest/globalTeardown.js +1 -0
  61. package/runners/jest/index.d.ts +60 -0
  62. package/runners/jest/index.js +16 -0
  63. package/runners/jest/index.test.js +13 -0
  64. package/runners/jest/reporter.js +1 -0
  65. package/runners/jest/reporters/DetoxReporter.js +36 -0
  66. package/runners/jest/specReporter.d.ts +4 -9
  67. package/runners/jest/specReporter.js +3 -10
  68. package/runners/jest/streamlineReporter.js +3 -22
  69. package/runners/jest/testEnvironment/index.js +205 -0
  70. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +166 -0
  71. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
  72. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
  73. package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -9
  74. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +30 -0
  75. package/runners/jest/testEnvironment/listeners/index.js +13 -0
  76. package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
  77. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +70 -0
  78. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +22 -0
  79. package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
  80. package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
  81. package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
  82. package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
  83. package/runners/jest-circus/environment/index.js +6 -0
  84. package/runners/jest-circus/index.js +1 -10
  85. package/runners/jest-circus/reporter.js +1 -0
  86. package/runners/migration.js +37 -0
  87. package/runners/mocha/DetoxMochaAdapter.js +3 -35
  88. package/runners/mocha/adapter.d.ts +4 -7
  89. package/runners/mocha/adapter.js +3 -5
  90. package/src/DetoxWorker.js +327 -0
  91. package/src/android/interactions/native.js +2 -1
  92. package/src/artifacts/ArtifactsManager.js +51 -35
  93. package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
  94. package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
  95. package/src/artifacts/providers/index.js +0 -4
  96. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
  97. package/src/artifacts/templates/artifact/Artifact.js +1 -1
  98. package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
  99. package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
  100. package/src/artifacts/utils/temporaryPath.js +18 -5
  101. package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
  102. package/src/client/AsyncWebSocket.js +8 -17
  103. package/src/client/Client.js +1 -1
  104. package/src/client/actions/actions.js +2 -2
  105. package/src/configuration/collectCliConfig.js +3 -16
  106. package/src/configuration/composeAppsConfig.js +12 -66
  107. package/src/configuration/composeArtifactsConfig.js +6 -32
  108. package/src/configuration/composeBehaviorConfig.js +3 -13
  109. package/src/configuration/composeDeviceConfig.js +38 -63
  110. package/src/configuration/composeLoggerConfig.js +59 -0
  111. package/src/configuration/composeRunnerConfig.js +127 -14
  112. package/src/configuration/composeSessionConfig.js +1 -3
  113. package/src/configuration/index.js +36 -30
  114. package/src/configuration/loadExternalConfig.js +1 -1
  115. package/src/configuration/utils/deviceAppTypes.js +0 -1
  116. package/src/devices/allocation/DeviceAllocator.js +4 -2
  117. package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +1 -1
  118. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +5 -3
  119. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
  120. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -5
  121. package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
  122. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
  123. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
  124. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
  125. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
  126. package/src/devices/allocation/factories/index.js +0 -1
  127. package/src/devices/common/drivers/DeviceLauncher.js +2 -2
  128. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
  129. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
  130. package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  131. package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
  132. package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
  133. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +35 -10
  134. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
  135. package/src/devices/runtime/RuntimeDevice.js +85 -86
  136. package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
  137. package/src/devices/runtime/drivers/android/AndroidDriver.js +3 -3
  138. package/src/devices/runtime/drivers/index.js +0 -1
  139. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +4 -3
  140. package/src/devices/runtime/factories/ios.js +1 -8
  141. package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
  142. package/src/devices/runtime/utils/Storage.js +4 -0
  143. package/src/environmentFactory.js +0 -8
  144. package/src/errors/DetoxConfigErrorComposer.js +92 -30
  145. package/src/errors/DetoxError.js +4 -0
  146. package/src/errors/DetoxRuntimeError.js +5 -5
  147. package/src/errors/index.js +2 -0
  148. package/src/ios/expectTwo.js +2 -1
  149. package/src/ipc/IPCClient.js +117 -0
  150. package/src/ipc/IPCServer.js +98 -0
  151. package/src/ipc/SessionState.js +62 -0
  152. package/src/logger/DetoxLogger.js +348 -0
  153. package/src/logger/index.js +5 -0
  154. package/src/logger/utils/BunyanLogger.js +76 -0
  155. package/src/logger/utils/CategoryThreadDispatcher.js +36 -0
  156. package/src/logger/utils/DetoxLogFinalizer.js +140 -0
  157. package/src/logger/utils/MessageStack.js +24 -0
  158. package/src/logger/utils/ThreadDispatcher.js +61 -0
  159. package/src/{utils → logger/utils}/customConsoleLogger.js +5 -4
  160. package/src/logger/utils/sanitizeBunyanContext.js +30 -0
  161. package/src/logger/utils/streamUtils.js +248 -0
  162. package/src/logger/utils/tracerLegacy.js +37 -0
  163. package/src/realms/DetoxConstants.js +13 -0
  164. package/src/realms/DetoxContext.js +183 -0
  165. package/src/realms/DetoxInternalsFacade.js +31 -0
  166. package/src/realms/DetoxPrimaryContext.js +261 -0
  167. package/src/realms/DetoxSecondaryContext.js +91 -0
  168. package/src/realms/index.js +10 -0
  169. package/src/realms/primary.js +3 -0
  170. package/src/realms/secondary.js +3 -0
  171. package/src/server/DetoxConnection.js +18 -23
  172. package/src/server/DetoxServer.js +7 -10
  173. package/src/server/DetoxSession.js +6 -6
  174. package/src/server/DetoxSessionManager.js +1 -1
  175. package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
  176. package/src/symbols.js +50 -0
  177. package/src/utils/Timer.js +58 -33
  178. package/src/utils/argparse.js +11 -0
  179. package/src/utils/childProcess/exec.js +1 -1
  180. package/src/utils/childProcess/spawn.js +1 -1
  181. package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
  182. package/src/utils/errorUtils.js +20 -0
  183. package/src/utils/logger.js +2 -162
  184. package/src/utils/shellUtils.js +18 -0
  185. package/src/utils/traceInvocationCall.js +21 -0
  186. package/src/utils/traceMethods.js +15 -0
  187. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.md5 +0 -1
  188. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha1 +0 -1
  189. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha256 +0 -1
  190. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha512 +0 -1
  191. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.md5 +0 -1
  192. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha1 +0 -1
  193. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha256 +0 -1
  194. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha512 +0 -1
  195. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar +0 -0
  196. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.md5 +0 -1
  197. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha1 +0 -1
  198. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha256 +0 -1
  199. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha512 +0 -1
  200. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.md5 +0 -1
  201. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha1 +0 -1
  202. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha256 +0 -1
  203. package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha512 +0 -1
  204. package/local-cli/templates/mocha.js +0 -32
  205. package/local-cli/utils/splitArgv.js +0 -107
  206. package/runners/integration.js +0 -16
  207. package/runners/jest/DetoxAdapterCircus.js +0 -60
  208. package/runners/jest/DetoxAdapterImpl.js +0 -81
  209. package/runners/jest/DetoxAdapterJasmine.js +0 -67
  210. package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
  211. package/runners/jest/FailingTestsReporter.js +0 -16
  212. package/runners/jest/SpecReporterCircus.js +0 -51
  213. package/runners/jest/SpecReporterJasmine.js +0 -39
  214. package/runners/jest/WorkerAssignReporterCircus.js +0 -17
  215. package/runners/jest/WorkerAssignReporterImpl.js +0 -21
  216. package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
  217. package/runners/jest/runnerInfo.js +0 -9
  218. package/runners/jest-circus/environment.js +0 -206
  219. package/runners/jest-circus/listeners/DetoxCoreListener.js +0 -113
  220. package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
  221. package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
  222. package/src/Detox.js +0 -317
  223. package/src/DetoxConstants.js +0 -13
  224. package/src/DetoxExportWrapper.js +0 -140
  225. package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -92
  226. package/src/configuration/utils/warnings.js +0 -12
  227. package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
  228. package/src/devices/allocation/factories/none.js +0 -11
  229. package/src/index.js +0 -6
  230. package/src/utils/ChromeTracingExporter.js +0 -54
  231. package/src/utils/MissingDetox.js +0 -78
  232. package/src/utils/fakeTimestampsProvider.js +0 -9
  233. package/src/utils/getWorkerId.js +0 -5
  234. package/src/utils/lastFailedTests.js +0 -38
  235. package/src/utils/sh.js +0 -18
  236. package/src/utils/trace.js +0 -96
@@ -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,16 @@ 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
+ // TODO: remove this ignore as soon as DetoxPrimaryContext is covered with tests
14
+ /* istanbul ignore next */
15
+ async globalInit() {}
16
+
17
+ emergencyCleanup() {
18
+ const { rawDevices } = this._deviceCleanupRegistry.readRegisteredDevicesUNSAFE();
19
+ const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
20
+ if (instanceHandles.length) {
21
+ reportGlobalCleanupSummary(instanceHandles);
22
+ }
25
23
  }
26
24
 
27
25
  async globalCleanup() {
@@ -34,7 +32,7 @@ class GenyGlobalLifecycleHandler {
34
32
  }
35
33
 
36
34
  async function doSafeCleanup(instanceLifecycleService, instanceHandles) {
37
- logger.info(cleanupLogData, 'Initiating Genymotion cloud instances teardown...');
35
+ logger.info(cleanupLogData, 'Initiating Genymotion SaaS instances teardown...');
38
36
 
39
37
  const deletionLeaks = [];
40
38
  const killPromises = instanceHandles.map((instanceHandle) =>
@@ -47,7 +45,7 @@ async function doSafeCleanup(instanceLifecycleService, instanceHandles) {
47
45
 
48
46
  function reportGlobalCleanupSummary(deletionLeaks) {
49
47
  if (deletionLeaks.length) {
50
- logger.warn(cleanupLogData, 'WARNING! Detected a Genymotion cloud instance leakage, for the following instances:');
48
+ logger.warn(cleanupLogData, 'WARNING! Detected a Genymotion SaaS instance leakage, for the following instances:');
51
49
 
52
50
  deletionLeaks.forEach(({ uuid, name, error }) => {
53
51
  logger.warn(cleanupLogData, [
@@ -1,6 +1,7 @@
1
1
  const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
2
2
  const debug = require('../../utils/debug'); // debug utils, leave here even if unused
3
- const { traceCall } = require('../../utils/trace');
3
+ const log = require('../../utils/logger').child({ cat: 'device' });
4
+ const traceMethods = require('../../utils/traceMethods');
4
5
  const wrapWithStackTraceCutter = require('../../utils/wrapWithStackTraceCutter');
5
6
 
6
7
  const LaunchArgsEditor = require('./utils/LaunchArgsEditor');
@@ -14,12 +15,13 @@ class RuntimeDevice {
14
15
  sessionConfig,
15
16
  runtimeErrorComposer,
16
17
  }, deviceDriver) {
17
- wrapWithStackTraceCutter(this, [
18
+ const methodNames = [
18
19
  'captureViewHierarchy',
19
20
  'clearKeychain',
20
21
  'disableSynchronization',
21
22
  'enableSynchronization',
22
23
  'installApp',
24
+ 'installUtilBinaries',
23
25
  'launchApp',
24
26
  'matchFace',
25
27
  'matchFinger',
@@ -46,7 +48,10 @@ class RuntimeDevice {
46
48
  'unmatchFace',
47
49
  'unmatchFinger',
48
50
  'unreverseTcpPort',
49
- ]);
51
+ ];
52
+
53
+ traceMethods(log, this, methodNames);
54
+ wrapWithStackTraceCutter(this, methodNames);
50
55
 
51
56
  this._appsConfig = appsConfig;
52
57
  this._behaviorConfig = behaviorConfig;
@@ -80,13 +85,6 @@ class RuntimeDevice {
80
85
  return this._currentAppLaunchArgs;
81
86
  }
82
87
 
83
- async _prepare() {
84
- const appAliases = Object.keys(this._appsConfig);
85
- if (appAliases.length === 1) {
86
- await this.selectApp(appAliases[0]);
87
- }
88
- }
89
-
90
88
  async selectApp(name) {
91
89
  if (name === undefined) {
92
90
  throw this._errorComposer.cantSelectEmptyApp();
@@ -113,12 +111,71 @@ class RuntimeDevice {
113
111
  }
114
112
 
115
113
  async launchApp(params = {}, bundleId = this._bundleId) {
116
- return traceCall('launch app', this._doLaunchApp(params, bundleId));
114
+ const payloadParams = ['url', 'userNotification', 'userActivity'];
115
+ const hasPayload = this._assertHasSingleParam(payloadParams, params);
116
+ const newInstance = params.newInstance !== undefined
117
+ ? params.newInstance
118
+ : this._processes[bundleId] == null;
119
+
120
+ if (params.delete) {
121
+ await this.terminateApp(bundleId);
122
+ await this.uninstallApp();
123
+ await this.installApp();
124
+ } else if (newInstance) {
125
+ await this.terminateApp(bundleId);
126
+ }
127
+
128
+ const baseLaunchArgs = {
129
+ ...this._currentAppLaunchArgs.get(),
130
+ ...params.launchArgs,
131
+ };
132
+
133
+ if (params.url) {
134
+ baseLaunchArgs['detoxURLOverride'] = params.url;
135
+ if (params.sourceApp) {
136
+ baseLaunchArgs['detoxSourceAppOverride'] = params.sourceApp;
137
+ }
138
+ } else if (params.userNotification) {
139
+ this._createPayloadFileAndUpdatesParamsObject('userNotification', 'detoxUserNotificationDataURL', params, baseLaunchArgs);
140
+ } else if (params.userActivity) {
141
+ this._createPayloadFileAndUpdatesParamsObject('userActivity', 'detoxUserActivityDataURL', params, baseLaunchArgs);
142
+ }
143
+
144
+ if (params.permissions) {
145
+ await this.deviceDriver.setPermissions(bundleId, params.permissions);
146
+ }
147
+
148
+ if (params.disableTouchIndicators) {
149
+ baseLaunchArgs['detoxDisableTouchIndicators'] = true;
150
+ }
151
+
152
+ if (this._isAppRunning(bundleId) && hasPayload) {
153
+ await this.deviceDriver.deliverPayload({ ...(params), delayPayload: true });
154
+ }
155
+
156
+ if (this._behaviorConfig.launchApp === 'manual') {
157
+ this._processes[bundleId] = await this.deviceDriver.waitForAppLaunch(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
158
+ } else {
159
+ this._processes[bundleId] = await this.deviceDriver.launchApp(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
160
+ await this.deviceDriver.waitUntilReady();
161
+ await this.deviceDriver.waitForActive();
162
+ }
163
+
164
+ await this._emitter.emit('appReady', {
165
+ deviceId: this.deviceDriver.getExternalId(),
166
+ bundleId,
167
+ pid: this._processes[bundleId],
168
+ });
169
+
170
+ if (params.detoxUserNotificationDataURL) {
171
+ await this.deviceDriver.cleanupRandomDirectory(params.detoxUserNotificationDataURL);
172
+ }
173
+
174
+ if (params.detoxUserActivityDataURL) {
175
+ await this.deviceDriver.cleanupRandomDirectory(params.detoxUserActivityDataURL);
176
+ }
117
177
  }
118
178
 
119
- /**
120
- * @deprecated
121
- */
122
179
  async relaunchApp(params = {}, bundleId) {
123
180
  if (params.newInstance === undefined) {
124
181
  params['newInstance'] = true;
@@ -180,24 +237,33 @@ class RuntimeDevice {
180
237
 
181
238
  async installApp(binaryPath, testBinaryPath) {
182
239
  const currentApp = binaryPath ? { binaryPath, testBinaryPath } : this._getCurrentApp();
183
- await traceCall('appInstall',
184
- this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath));
240
+ await this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath);
241
+
242
+ // This abstraction leaks because our drivers themselves leak,
243
+ // so don't blame me - DeviceBaseDriver itself has `reverseTcpPort`,
244
+ // setting a vicious downward spiral. I can't refactor everything
245
+ // in a single pull request, so let's bear with it for now.
246
+ if (Array.isArray(currentApp.reversePorts)) {
247
+ for (const port of currentApp.reversePorts) {
248
+ await this.reverseTcpPort(port);
249
+ }
250
+ }
185
251
  }
186
252
 
187
253
  async uninstallApp(bundleId) {
188
254
  const _bundleId = bundleId || this._bundleId;
189
- await traceCall('appUninstall', this.deviceDriver.uninstallApp(_bundleId));
255
+ await this.deviceDriver.uninstallApp(_bundleId);
190
256
  }
191
257
 
192
258
  async installUtilBinaries() {
193
259
  const paths = this._deviceConfig.utilBinaryPaths;
194
260
  if (paths) {
195
- await traceCall('installUtilBinaries', this.deviceDriver.installUtilBinaries(paths));
261
+ await this.deviceDriver.installUtilBinaries(paths);
196
262
  }
197
263
  }
198
264
 
199
265
  async reloadReactNative() {
200
- await traceCall('reload React Native', this.deviceDriver.reloadReactNative());
266
+ await this.deviceDriver.reloadReactNative();
201
267
  }
202
268
 
203
269
  async openURL(params) {
@@ -296,73 +362,6 @@ class RuntimeDevice {
296
362
  }
297
363
  return this._currentApp;
298
364
  }
299
-
300
- async _doLaunchApp(params, bundleId) {
301
- const payloadParams = ['url', 'userNotification', 'userActivity'];
302
- const hasPayload = this._assertHasSingleParam(payloadParams, params);
303
- const newInstance = params.newInstance !== undefined
304
- ? params.newInstance
305
- : this._processes[bundleId] == null;
306
-
307
- if (params.delete) {
308
- await this.terminateApp(bundleId);
309
- await this.uninstallApp();
310
- await this.installApp();
311
- } else if (newInstance) {
312
- await this.terminateApp(bundleId);
313
- }
314
-
315
- const baseLaunchArgs = {
316
- ...this._currentAppLaunchArgs.get(),
317
- ...params.launchArgs,
318
- };
319
-
320
- if (params.url) {
321
- baseLaunchArgs['detoxURLOverride'] = params.url;
322
- if (params.sourceApp) {
323
- baseLaunchArgs['detoxSourceAppOverride'] = params.sourceApp;
324
- }
325
- } else if (params.userNotification) {
326
- this._createPayloadFileAndUpdatesParamsObject('userNotification', 'detoxUserNotificationDataURL', params, baseLaunchArgs);
327
- } else if (params.userActivity) {
328
- this._createPayloadFileAndUpdatesParamsObject('userActivity', 'detoxUserActivityDataURL', params, baseLaunchArgs);
329
- }
330
-
331
- if (params.permissions) {
332
- await this.deviceDriver.setPermissions(bundleId, params.permissions);
333
- }
334
-
335
- if (params.disableTouchIndicators) {
336
- baseLaunchArgs['detoxDisableTouchIndicators'] = true;
337
- }
338
-
339
- if (this._isAppRunning(bundleId) && hasPayload) {
340
- await this.deviceDriver.deliverPayload({ ...params, delayPayload: true });
341
- }
342
-
343
- if (this._behaviorConfig.launchApp === 'manual') {
344
- this._processes[bundleId] = await this.deviceDriver.waitForAppLaunch(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
345
- } else {
346
- this._processes[bundleId] = await this.deviceDriver.launchApp(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
347
- await this.deviceDriver.waitUntilReady();
348
- await this.deviceDriver.waitForActive();
349
- }
350
-
351
- await this._emitter.emit('appReady', {
352
- deviceId: this.deviceDriver.getExternalId(),
353
- bundleId,
354
- pid: this._processes[bundleId],
355
- });
356
-
357
- if(params.detoxUserNotificationDataURL) {
358
- await this.deviceDriver.cleanupRandomDirectory(params.detoxUserNotificationDataURL);
359
- }
360
-
361
- if(params.detoxUserActivityDataURL) {
362
- await this.deviceDriver.cleanupRandomDirectory(params.detoxUserActivityDataURL);
363
- }
364
- }
365
-
366
365
  async _sendPayload(key, params) {
367
366
  const payloadFilePath = this.deviceDriver.createPayloadFile(params);
368
367
  const payload = {
@@ -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
@@ -153,9 +153,9 @@ class AndroidDriver extends DeviceDriverBase {
153
153
  this.instrumentation.waitForCrash()
154
154
  ]);
155
155
  } catch (e) {
156
- console.warn('An error occurred while waiting for the app to become ready. Waiting for disconnection... Error:\n', e);
156
+ log.warn({ error: e }, 'An error occurred while waiting for the app to become ready. Waiting for disconnection...');
157
157
  await this.client.waitUntilDisconnected();
158
- console.warn('...app disconnected.');
158
+ log.warn('The app disconnected.');
159
159
  throw e;
160
160
  } finally {
161
161
  this.instrumentation.abortWaitForCrash();
@@ -2,6 +2,5 @@ module.exports = {
2
2
  AndroidEmulatorRuntimeDriver: require('./android/emulator/EmulatorDriver'),
3
3
  AttachedAndroidRuntimeDriver: require('./android/attached/AttachedAndroidDriver'),
4
4
  GenycloudRuntimeDriver: require('./android/genycloud/GenyCloudDriver'),
5
- IosRuntimeDriver: require('./ios/IosDriver'),
6
5
  IosSimulatorRuntimeDriver: require('./ios/SimulatorDriver'),
7
6
  };
@@ -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');
@@ -30,12 +30,13 @@ class SimulatorDriver extends IosDriver {
30
30
  * @param deps { SimulatorDriverDeps }
31
31
  * @param props { SimulatorDriverProps }
32
32
  */
33
- constructor(deps, { udid, type, bootArgs }) {
33
+ constructor(deps, { udid, type, bootArgs, headless }) {
34
34
  super(deps);
35
35
 
36
36
  this.udid = udid;
37
37
  this._type = type;
38
38
  this._bootArgs = bootArgs;
39
+ this._headless = headless;
39
40
  this._deviceName = `${udid} (${this._type})`;
40
41
  this._simulatorLauncher = deps.simulatorLauncher;
41
42
  this._applesimutils = deps.applesimutils;
@@ -151,7 +152,7 @@ class SimulatorDriver extends IosDriver {
151
152
  async resetContentAndSettings() {
152
153
  await this._simulatorLauncher.shutdown(this.udid);
153
154
  await this._applesimutils.resetContentAndSettings(this.udid);
154
- await this._simulatorLauncher.launch(this.udid, this._type, this._bootArgs);
155
+ await this._simulatorLauncher.launch(this.udid, this._type, this._bootArgs, this._headless);
155
156
  }
156
157
 
157
158
  getLogsPaths() {
@@ -15,19 +15,13 @@ class RuntimeDriverFactoryIos extends RuntimeDeviceFactory {
15
15
  }
16
16
  }
17
17
 
18
- class Ios extends RuntimeDriverFactoryIos {
19
- _createDriver(deviceCookie, deps, configs) { // eslint-disable-line no-unused-vars
20
- const { IosRuntimeDriver } = require('../drivers');
21
- return new IosRuntimeDriver(deps);
22
- }
23
- }
24
-
25
18
  class IosSimulator extends RuntimeDriverFactoryIos {
26
19
  _createDriver(deviceCookie, deps, { deviceConfig }) {
27
20
  const props = {
28
21
  udid: deviceCookie.udid,
29
22
  type: deviceConfig.device.type,
30
23
  bootArgs: deviceConfig.bootArgs,
24
+ headless: deviceConfig.headless
31
25
  };
32
26
 
33
27
  const { IosSimulatorRuntimeDriver } = require('../drivers');
@@ -36,6 +30,5 @@ class IosSimulator extends RuntimeDriverFactoryIos {
36
30
  }
37
31
 
38
32
  module.exports = {
39
- Ios,
40
33
  IosSimulator,
41
34
  };
@@ -1,14 +1,7 @@
1
1
  const _ = require('lodash');
2
2
 
3
- const log = require('../../../utils/logger');
4
-
5
3
  const ScopedLaunchArgsEditor = require('./ScopedLaunchArgsEditor');
6
4
 
7
- /**
8
- * @typedef {Object} LaunchArgsEditorOptions
9
- * @property {boolean} [permanent=false] - Indicates whether the operation should affect the permanent app launch args.
10
- */
11
-
12
5
  class LaunchArgsEditor {
13
6
  constructor() {
14
7
  this._local = new ScopedLaunchArgsEditor();
@@ -19,67 +12,19 @@ class LaunchArgsEditor {
19
12
  return this._shared;
20
13
  }
21
14
 
22
- /**
23
- * @param {LaunchArgsEditorOptions} [options] - deprecated
24
- */
25
- modify(launchArgs, options) {
26
- this._assertNoDeprecatedOptions('modify', options);
27
-
28
- if (!_.isEmpty(launchArgs)) {
29
- if (options && options.permanent) {
30
- this._shared.modify(launchArgs);
31
- } else {
32
- this._local.modify(launchArgs);
33
- }
34
- }
35
-
15
+ modify(launchArgs) {
16
+ this._local.modify(launchArgs);
36
17
  return this;
37
18
  }
38
19
 
39
- /**
40
- * @param {LaunchArgsEditorOptions} [options] - deprecated
41
- */
42
- reset(options) {
43
- this._assertNoDeprecatedOptions('reset', options);
20
+ reset() {
44
21
  this._local.reset();
45
-
46
- if (options && options.permanent) {
47
- this._shared.reset();
48
- }
49
-
50
22
  return this;
51
23
  }
52
24
 
53
- /**
54
- * @param {LaunchArgsEditorOptions} [options] - deprecated
55
- */
56
- get(options) {
57
- this._assertNoDeprecatedOptions('get', options);
58
- const permanent = options && options.permanent;
59
-
60
- if (permanent === true) {
61
- return this._shared.get();
62
- }
63
-
64
- if (permanent === false) {
65
- return this._local.get();
66
- }
67
-
25
+ get() {
68
26
  return _.merge(this._shared.get(), this._local.get());
69
27
  }
70
-
71
- _assertNoDeprecatedOptions(methodName, options) {
72
- if (!options) {
73
- return;
74
- }
75
-
76
- const target = options.permanent ? 'appLaunchArgs.shared' : 'appLaunchArgs';
77
- log.warn({ event: 'DEPRECATION' }, [
78
- `Detected an attempt to use device.launchArgs.${methodName}(...) with a deprecated 'options' parameter.`,
79
- `Please use device.${target}.${methodName}(...) instead.`,
80
- `For more details, see the reference at: https://wix.github.io/Detox/docs/api/device-object-api#deviceapplaunchargs\n`,
81
- ].join('\n'));
82
- }
83
28
  }
84
29
 
85
30
  module.exports = LaunchArgsEditor;
@@ -14,6 +14,10 @@ class Storage {
14
14
  }
15
15
 
16
16
  assign(map) {
17
+ if (_.isEmpty(map)) {
18
+ return;
19
+ }
20
+
17
21
  for (const key of Object.keys(map)) {
18
22
  this.set(key, map[key]);
19
23
  }
@@ -85,14 +85,6 @@ function _getFactoryClasses(deviceConfig) {
85
85
  runtimeDeviceFactoryClass = runtimeDeviceFactories.IosSimulator;
86
86
  break;
87
87
 
88
- case 'ios.none':
89
- envValidatorFactoryClass = envValidationFactories.Noop;
90
- deviceAllocatorFactoryClass = deviceAllocationFactories.None;
91
- artifactsManagerFactoryClass = artifactsManagerFactories.Ios;
92
- matchersFactoryClass = matchersFactories.Ios;
93
- runtimeDeviceFactoryClass = runtimeDeviceFactories.Ios;
94
- break;
95
-
96
88
  default: {
97
89
  return null;
98
90
  }