detox 19.9.0 → 21.0.0-breaking.new-global-lifecycle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0-javadoc.jar → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0-sources.jar → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0.pom → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom} +2 -2
  17. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-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/android/build.gradle +2 -2
  29. package/android/detox/build.gradle +2 -2
  30. package/android/detox/publish-pom.gradle +1 -5
  31. package/android/detox/publishing.gradle +7 -9
  32. package/android/detox/src/full/java/com/wix/detox/Detox.java +2 -59
  33. package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
  34. package/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +1 -3
  35. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +3 -1
  36. package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +1 -1
  37. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +23 -16
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeLoadingMonitor.kt +8 -54
  39. package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +1 -4
  40. package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +1 -2
  41. package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +36 -0
  42. package/android/detox/src/{full → main}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +1 -13
  43. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt +1 -1
  44. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +59 -0
  45. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +3 -15
  46. package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
  47. package/android/gradlew +107 -181
  48. package/index.d.ts +208 -186
  49. package/index.js +1 -0
  50. package/internals.d.ts +124 -0
  51. package/internals.js +4 -0
  52. package/local-cli/build-framework-cache.js +2 -2
  53. package/local-cli/build.js +7 -8
  54. package/local-cli/build.test.js +46 -40
  55. package/local-cli/clean-framework-cache.js +3 -3
  56. package/local-cli/cli.js +0 -1
  57. package/local-cli/init.js +20 -55
  58. package/local-cli/templates/jest.js +9 -34
  59. package/local-cli/test.js +18 -282
  60. package/local-cli/test.test.js +332 -673
  61. package/local-cli/testCommand/TestRunnerCommand.js +157 -0
  62. package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
  63. package/local-cli/testCommand/middlewares.js +75 -0
  64. package/local-cli/{utils → testCommand}/warnings.js +0 -10
  65. package/local-cli/utils/jestInternals.js +13 -2
  66. package/local-cli/utils/yargsUtils.js +67 -0
  67. package/package.json +28 -22
  68. package/runners/deprecation.js +47 -0
  69. package/runners/jest/JestCircusEnvironment.js +3 -38
  70. package/runners/jest/adapter.d.ts +4 -10
  71. package/runners/jest/adapter.js +3 -6
  72. package/runners/jest/assignReporter.d.ts +4 -1
  73. package/runners/jest/assignReporter.js +3 -6
  74. package/runners/jest/deprecation.js +25 -0
  75. package/runners/jest/globalSetup.js +1 -0
  76. package/runners/jest/globalTeardown.js +1 -0
  77. package/runners/jest/index.js +21 -0
  78. package/runners/jest/reporter.js +1 -0
  79. package/runners/jest/reporters/DetoxReporter.js +5 -0
  80. package/runners/jest/specReporter.d.ts +4 -9
  81. package/runners/jest/specReporter.js +3 -10
  82. package/runners/jest/streamlineReporter.js +3 -22
  83. package/runners/jest/testEnvironment/index.js +155 -0
  84. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +35 -17
  85. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
  86. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
  87. package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -7
  88. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -0
  89. package/runners/jest/testEnvironment/listeners/index.js +13 -0
  90. package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
  91. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +56 -0
  92. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -0
  93. package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
  94. package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
  95. package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
  96. package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
  97. package/runners/jest-circus/environment/index.js +6 -0
  98. package/runners/jest-circus/index.js +1 -10
  99. package/runners/jest-circus/reporter.js +1 -0
  100. package/runners/migration.js +37 -0
  101. package/runners/mocha/DetoxMochaAdapter.js +3 -35
  102. package/runners/mocha/adapter.d.ts +4 -7
  103. package/runners/mocha/adapter.js +3 -5
  104. package/src/{Detox.js → DetoxWorker.js} +131 -164
  105. package/src/artifacts/ArtifactsManager.js +51 -2
  106. package/src/artifacts/log/android/ADBLogcatRecording.js +28 -11
  107. package/src/artifacts/providers/index.js +0 -4
  108. package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
  109. package/src/artifacts/utils/temporaryPath.js +2 -0
  110. package/src/client/AsyncWebSocket.js +1 -1
  111. package/src/client/actions/actions.js +2 -2
  112. package/src/configuration/collectCliConfig.js +2 -4
  113. package/src/configuration/composeAppsConfig.js +9 -67
  114. package/src/configuration/composeArtifactsConfig.js +6 -32
  115. package/src/configuration/composeBehaviorConfig.js +3 -13
  116. package/src/configuration/composeDeviceConfig.js +37 -62
  117. package/src/configuration/composeLoggerConfig.js +50 -0
  118. package/src/configuration/composeRunnerConfig.js +74 -14
  119. package/src/configuration/composeSessionConfig.js +1 -3
  120. package/src/configuration/index.js +24 -23
  121. package/src/configuration/utils/deviceAppTypes.js +0 -1
  122. package/src/devices/allocation/DeviceAllocator.js +3 -3
  123. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  124. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
  125. package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +0 -1
  126. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
  127. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
  128. package/src/devices/allocation/factories/index.js +0 -1
  129. package/src/devices/common/drivers/DeviceLauncher.js +2 -2
  130. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
  131. package/src/devices/common/drivers/android/exec/ADB.js +0 -5
  132. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
  133. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +34 -9
  134. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
  135. package/src/devices/runtime/RuntimeDevice.js +69 -81
  136. package/src/devices/runtime/drivers/index.js +0 -1
  137. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
  138. package/src/devices/runtime/factories/ios.js +1 -8
  139. package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
  140. package/src/devices/runtime/utils/Storage.js +4 -0
  141. package/src/environmentFactory.js +0 -8
  142. package/src/errors/DetoxConfigErrorComposer.js +76 -29
  143. package/src/errors/DetoxError.js +4 -0
  144. package/src/errors/DetoxRuntimeError.js +5 -5
  145. package/src/errors/index.js +2 -0
  146. package/src/ipc/IPCClient.js +117 -0
  147. package/src/ipc/IPCServer.js +87 -0
  148. package/src/ipc/state.js +76 -0
  149. package/src/logger/DetoxLogger.js +244 -0
  150. package/src/logger/DetoxTraceEventBuilder.js +21 -0
  151. package/src/logger/DetoxTracer.js +133 -0
  152. package/src/logger/TraceThreadDispatcher.js +52 -0
  153. package/src/{utils → logger}/customConsoleLogger.js +1 -1
  154. package/src/realms/DetoxConstants.js +13 -0
  155. package/src/realms/DetoxContext.js +170 -0
  156. package/src/realms/DetoxInternalsFacade.js +35 -0
  157. package/src/realms/DetoxPrimaryContext.js +229 -0
  158. package/src/realms/DetoxSecondaryContext.js +94 -0
  159. package/src/realms/index.js +10 -0
  160. package/src/realms/primary.js +3 -0
  161. package/src/realms/secondary.js +3 -0
  162. package/src/server/DetoxConnection.js +1 -1
  163. package/src/symbols.js +56 -0
  164. package/src/utils/ChromeTracingExporter.js +5 -6
  165. package/src/utils/Timer.js +14 -6
  166. package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
  167. package/src/utils/logger.js +2 -162
  168. package/src/utils/shellUtils.js +18 -0
  169. package/src/utils/streamUtils.js +214 -0
  170. package/src/utils/trace.js +9 -44
  171. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.md5 +0 -1
  172. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha1 +0 -1
  173. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha256 +0 -1
  174. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha512 +0 -1
  175. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.md5 +0 -1
  176. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha1 +0 -1
  177. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha256 +0 -1
  178. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha512 +0 -1
  179. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar +0 -0
  180. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.md5 +0 -1
  181. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha1 +0 -1
  182. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha256 +0 -1
  183. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha512 +0 -1
  184. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.md5 +0 -1
  185. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha1 +0 -1
  186. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha256 +0 -1
  187. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha512 +0 -1
  188. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -22
  189. package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +0 -75
  190. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +0 -10
  191. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +0 -39
  192. package/local-cli/templates/mocha.js +0 -32
  193. package/local-cli/utils/splitArgv.js +0 -107
  194. package/runners/integration.js +0 -16
  195. package/runners/jest/DetoxAdapterCircus.js +0 -60
  196. package/runners/jest/DetoxAdapterImpl.js +0 -81
  197. package/runners/jest/DetoxAdapterJasmine.js +0 -67
  198. package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
  199. package/runners/jest/FailingTestsReporter.js +0 -16
  200. package/runners/jest/SpecReporterCircus.js +0 -51
  201. package/runners/jest/SpecReporterJasmine.js +0 -39
  202. package/runners/jest/WorkerAssignReporterCircus.js +0 -17
  203. package/runners/jest/WorkerAssignReporterImpl.js +0 -21
  204. package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
  205. package/runners/jest/runnerInfo.js +0 -9
  206. package/runners/jest-circus/environment.js +0 -206
  207. package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
  208. package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
  209. package/src/DetoxConstants.js +0 -13
  210. package/src/DetoxExportWrapper.js +0 -140
  211. package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -95
  212. package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
  213. package/src/devices/allocation/factories/none.js +0 -11
  214. package/src/index.js +0 -6
  215. package/src/utils/MissingDetox.js +0 -78
  216. package/src/utils/fakeTimestampsProvider.js +0 -9
  217. package/src/utils/getWorkerId.js +0 -5
  218. package/src/utils/lastFailedTests.js +0 -38
  219. package/src/utils/sh.js +0 -18
@@ -1,6 +1,6 @@
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 { traceCall, traceMethods } = require('../../utils/trace');
4
4
  const wrapWithStackTraceCutter = require('../../utils/wrapWithStackTraceCutter');
5
5
 
6
6
  const LaunchArgsEditor = require('./utils/LaunchArgsEditor');
@@ -14,7 +14,7 @@ class RuntimeDevice {
14
14
  sessionConfig,
15
15
  runtimeErrorComposer,
16
16
  }, deviceDriver) {
17
- wrapWithStackTraceCutter(this, [
17
+ const methodNames = [
18
18
  'captureViewHierarchy',
19
19
  'clearKeychain',
20
20
  'disableSynchronization',
@@ -46,7 +46,10 @@ class RuntimeDevice {
46
46
  'unmatchFace',
47
47
  'unmatchFinger',
48
48
  'unreverseTcpPort',
49
- ]);
49
+ ];
50
+
51
+ traceMethods(this, 'device', methodNames);
52
+ wrapWithStackTraceCutter(this, methodNames);
50
53
 
51
54
  this._appsConfig = appsConfig;
52
55
  this._behaviorConfig = behaviorConfig;
@@ -80,13 +83,6 @@ class RuntimeDevice {
80
83
  return this._currentAppLaunchArgs;
81
84
  }
82
85
 
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
86
  async selectApp(name) {
91
87
  if (name === undefined) {
92
88
  throw this._errorComposer.cantSelectEmptyApp();
@@ -113,12 +109,71 @@ class RuntimeDevice {
113
109
  }
114
110
 
115
111
  async launchApp(params = {}, bundleId = this._bundleId) {
116
- return traceCall('launchApp', () => this._doLaunchApp(params, bundleId));
112
+ const payloadParams = ['url', 'userNotification', 'userActivity'];
113
+ const hasPayload = this._assertHasSingleParam(payloadParams, params);
114
+ const newInstance = params.newInstance !== undefined
115
+ ? params.newInstance
116
+ : this._processes[bundleId] == null;
117
+
118
+ if (params.delete) {
119
+ await this.terminateApp(bundleId);
120
+ await this.uninstallApp();
121
+ await this.installApp();
122
+ } else if (newInstance) {
123
+ await this.terminateApp(bundleId);
124
+ }
125
+
126
+ const baseLaunchArgs = {
127
+ ...this._currentAppLaunchArgs.get(),
128
+ ...params.launchArgs,
129
+ };
130
+
131
+ if (params.url) {
132
+ baseLaunchArgs['detoxURLOverride'] = params.url;
133
+ if (params.sourceApp) {
134
+ baseLaunchArgs['detoxSourceAppOverride'] = params.sourceApp;
135
+ }
136
+ } else if (params.userNotification) {
137
+ this._createPayloadFileAndUpdatesParamsObject('userNotification', 'detoxUserNotificationDataURL', params, baseLaunchArgs);
138
+ } else if (params.userActivity) {
139
+ this._createPayloadFileAndUpdatesParamsObject('userActivity', 'detoxUserActivityDataURL', params, baseLaunchArgs);
140
+ }
141
+
142
+ if (params.permissions) {
143
+ await this.deviceDriver.setPermissions(bundleId, params.permissions);
144
+ }
145
+
146
+ if (params.disableTouchIndicators) {
147
+ baseLaunchArgs['detoxDisableTouchIndicators'] = true;
148
+ }
149
+
150
+ if (this._isAppRunning(bundleId) && hasPayload) {
151
+ await this.deviceDriver.deliverPayload({ ...(params), delayPayload: true });
152
+ }
153
+
154
+ if (this._behaviorConfig.launchApp === 'manual') {
155
+ this._processes[bundleId] = await this.deviceDriver.waitForAppLaunch(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
156
+ } else {
157
+ this._processes[bundleId] = await this.deviceDriver.launchApp(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
158
+ await this.deviceDriver.waitUntilReady();
159
+ await this.deviceDriver.waitForActive();
160
+ }
161
+
162
+ await this._emitter.emit('appReady', {
163
+ deviceId: this.deviceDriver.getExternalId(),
164
+ bundleId,
165
+ pid: this._processes[bundleId],
166
+ });
167
+
168
+ if (params.detoxUserNotificationDataURL) {
169
+ await this.deviceDriver.cleanupRandomDirectory(params.detoxUserNotificationDataURL);
170
+ }
171
+
172
+ if (params.detoxUserActivityDataURL) {
173
+ await this.deviceDriver.cleanupRandomDirectory(params.detoxUserActivityDataURL);
174
+ }
117
175
  }
118
176
 
119
- /**
120
- * @deprecated
121
- */
122
177
  async relaunchApp(params = {}, bundleId) {
123
178
  if (params.newInstance === undefined) {
124
179
  params['newInstance'] = true;
@@ -300,73 +355,6 @@ class RuntimeDevice {
300
355
  }
301
356
  return this._currentApp;
302
357
  }
303
-
304
- async _doLaunchApp(params, bundleId) {
305
- const payloadParams = ['url', 'userNotification', 'userActivity'];
306
- const hasPayload = this._assertHasSingleParam(payloadParams, params);
307
- const newInstance = params.newInstance !== undefined
308
- ? params.newInstance
309
- : this._processes[bundleId] == null;
310
-
311
- if (params.delete) {
312
- await this.terminateApp(bundleId);
313
- await this.uninstallApp();
314
- await this.installApp();
315
- } else if (newInstance) {
316
- await this.terminateApp(bundleId);
317
- }
318
-
319
- const baseLaunchArgs = {
320
- ...this._currentAppLaunchArgs.get(),
321
- ...params.launchArgs,
322
- };
323
-
324
- if (params.url) {
325
- baseLaunchArgs['detoxURLOverride'] = params.url;
326
- if (params.sourceApp) {
327
- baseLaunchArgs['detoxSourceAppOverride'] = params.sourceApp;
328
- }
329
- } else if (params.userNotification) {
330
- this._createPayloadFileAndUpdatesParamsObject('userNotification', 'detoxUserNotificationDataURL', params, baseLaunchArgs);
331
- } else if (params.userActivity) {
332
- this._createPayloadFileAndUpdatesParamsObject('userActivity', 'detoxUserActivityDataURL', params, baseLaunchArgs);
333
- }
334
-
335
- if (params.permissions) {
336
- await this.deviceDriver.setPermissions(bundleId, params.permissions);
337
- }
338
-
339
- if (params.disableTouchIndicators) {
340
- baseLaunchArgs['detoxDisableTouchIndicators'] = true;
341
- }
342
-
343
- if (this._isAppRunning(bundleId) && hasPayload) {
344
- await this.deviceDriver.deliverPayload({ ...params, delayPayload: true });
345
- }
346
-
347
- if (this._behaviorConfig.launchApp === 'manual') {
348
- this._processes[bundleId] = await this.deviceDriver.waitForAppLaunch(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
349
- } else {
350
- this._processes[bundleId] = await this.deviceDriver.launchApp(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
351
- await this.deviceDriver.waitUntilReady();
352
- await this.deviceDriver.waitForActive();
353
- }
354
-
355
- await this._emitter.emit('appReady', {
356
- deviceId: this.deviceDriver.getExternalId(),
357
- bundleId,
358
- pid: this._processes[bundleId],
359
- });
360
-
361
- if(params.detoxUserNotificationDataURL) {
362
- await this.deviceDriver.cleanupRandomDirectory(params.detoxUserNotificationDataURL);
363
- }
364
-
365
- if(params.detoxUserActivityDataURL) {
366
- await this.deviceDriver.cleanupRandomDirectory(params.detoxUserActivityDataURL);
367
- }
368
- }
369
-
370
358
  async _sendPayload(key, params) {
371
359
  const payloadFilePath = this.deviceDriver.createPayloadFile(params);
372
360
  const payload = {
@@ -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
  };
@@ -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
  }
@@ -25,16 +25,6 @@ class DetoxConfigErrorComposer {
25
25
  _atPath() {
26
26
  return this.filepath ? ` at path:\n${this.filepath}` : '.';
27
27
  }
28
-
29
- _inTheAppConfig() {
30
- const { type } = this._getSelectedConfiguration();
31
- if (type) {
32
- return `in configuration ${J(this.configurationName)}`;
33
- }
34
-
35
- return `in the app config`;
36
- }
37
-
38
28
  _getSelectedConfiguration() {
39
29
  return _.get(this.contents, ['configurations', this.configurationName]);
40
30
  }
@@ -64,9 +54,10 @@ class DetoxConfigErrorComposer {
64
54
  }
65
55
 
66
56
  _focusOnDeviceConfig(deviceAlias, postProcess = _.identity) {
67
- const { type, device } = this._getSelectedConfiguration();
57
+ const { device } = this._getSelectedConfiguration();
68
58
  if (!deviceAlias) {
69
- if (type || !device) {
59
+ // istanbul ignore next
60
+ if (!device) {
70
61
  return this._focusOnConfiguration(postProcess);
71
62
  } else {
72
63
  return this._focusOnConfiguration(c => {
@@ -92,8 +83,7 @@ class DetoxConfigErrorComposer {
92
83
  if (alias) {
93
84
  return this.contents.devices[alias];
94
85
  } else {
95
- const config = this._getSelectedConfiguration();
96
- return config.type ? config : config.device;
86
+ return this._getSelectedConfiguration().device;
97
87
  }
98
88
  }
99
89
 
@@ -225,6 +215,61 @@ Examine your Detox config${this._atPath()}`,
225
215
  });
226
216
  }
227
217
 
218
+ configurationShouldNotUseLegacyFormat() {
219
+ const name = this.configurationName;
220
+ const localConfig = this._getSelectedConfiguration();
221
+ /* istanbul ignore next */
222
+ const deviceType = localConfig.type || '';
223
+ const isAndroid = deviceType.startsWith('android.');
224
+ const isIOS = deviceType.startsWith('ios.');
225
+ const appName = 'myApp' + (isIOS ? '.ios' : '') + (isAndroid ? '.android' : '');
226
+ const deviceName = isIOS ? 'simulator' : isAndroid ? 'emulator' : 'myDevice';
227
+ const appType = isIOS ? 'ios.app' : isAndroid ? 'android.apk' : '<optional property>';
228
+ const binaryPath = isIOS || isAndroid ? localConfig.binaryPath : (localConfig.binaryPath || '<optional property>');
229
+ const deviceQuery = isIOS || isAndroid ? localConfig.device : (localConfig.device || '<optional property>');
230
+
231
+ return new DetoxConfigError({
232
+ message: `The ${J(name)} configuration utilizes a deprecated all-in-one schema, that is not supported ` +
233
+ `by the current version of Detox.`,
234
+ hint: `Remove the "type" property. A valid configuration is expected to have both the "device" and "app" aliases ` +
235
+ `pointing to the corresponding keys in the 'devices' and 'apps' config sections. For example:\n
236
+ {
237
+ "apps": {
238
+ *-->${J(appName)}: {
239
+ | "type": ${J(appType)},
240
+ | "binaryPath": ${J(binaryPath)},
241
+ | },
242
+ | },
243
+ | "devices": {
244
+ |*->${J(deviceName)}: {
245
+ || "type": ${J(deviceType)},
246
+ || "device": ${J(deviceQuery)}
247
+ || },
248
+ ||},
249
+ ||"configurations": {
250
+ || ${J(name)}: {
251
+ || /* REMOVE (!) "type": ${J(deviceType)} */
252
+ |*--- "device": ${J(deviceName)},
253
+ *---- "app": ${J(appName)},
254
+ ...
255
+ }
256
+ }
257
+ }
258
+ Examine your Detox config${this._atPath()}`,
259
+ debugInfo: {
260
+ apps: this.contents.apps
261
+ ? _.mapValues(this.contents.apps, _.constant({}))
262
+ : undefined,
263
+ devices: this.contents.devices
264
+ ? _.mapValues(this.contents.devices, _.constant({}))
265
+ : undefined,
266
+
267
+ ...this._focusOnConfiguration(),
268
+ },
269
+ inspectOptions: { depth: 2 }
270
+ });
271
+ }
272
+
228
273
  // endregion
229
274
 
230
275
  // region composeDeviceConfig
@@ -345,7 +390,7 @@ Please check your Detox config${this._atPath()}`,
345
390
  case 'forceAdbInstall':
346
391
  return this._invalidPropertyType('forceAdbInstall', 'a boolean value', deviceAlias);
347
392
  case 'gpuMode':
348
- return this._invalidPropertyType('gpuMode', "'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest'", deviceAlias);
393
+ return this._invalidPropertyType('gpuMode', "'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest' | 'off'", deviceAlias);
349
394
  case 'headless':
350
395
  return this._invalidPropertyType('headless', 'a boolean value', deviceAlias);
351
396
  case 'readonly':
@@ -456,7 +501,7 @@ Examine your Detox config${this._atPath()}`,
456
501
 
457
502
  malformedAppLaunchArgs(appPath) {
458
503
  return new DetoxConfigError({
459
- message: `Invalid type of "launchArgs" property ${this._inTheAppConfig()}.\nExpected an object:`,
504
+ message: `Invalid type of "launchArgs" property in the app config.\nExpected an object:`,
460
505
  debugInfo: this._focusOnAppConfig(appPath),
461
506
  inspectOptions: { depth: 4 },
462
507
  });
@@ -464,7 +509,7 @@ Examine your Detox config${this._atPath()}`,
464
509
 
465
510
  missingAppBinaryPath(appPath) {
466
511
  return new DetoxConfigError({
467
- message: `Missing "binaryPath" property ${this._inTheAppConfig()}.\nExpected a string:`,
512
+ message: `Missing "binaryPath" property in the app config.\nExpected a string:`,
468
513
  debugInfo: this._focusOnAppConfig(appPath, this._ensureProperty('binaryPath')),
469
514
  inspectOptions: { depth: 4 },
470
515
  });
@@ -538,18 +583,6 @@ Examine your Detox config${this._atPath()}`,
538
583
  });
539
584
  }
540
585
 
541
- oldSchemaHasAppAndApps() {
542
- return new DetoxConfigError({
543
- message: `Your configuration ${J(this.configurationName)} appears to be in a legacy format, which can’t contain "app" or "apps".`,
544
- hint: `Remove "type" property from configuration and use "device" property instead:\n` +
545
- `a) "device": { "type": ${J(this._getSelectedConfiguration().type)}, ... }\n` +
546
- `b) "device": "<alias-to-device>" // you should add that device configuration to "devices" with the same key` +
547
- `\n\nCheck your Detox config${this._atPath()}`,
548
- debugInfo: this._focusOnConfiguration(this._ensureProperty('type', 'device')),
549
- inspectOptions: { depth: 2 },
550
- });
551
- }
552
-
553
586
  ambiguousAppAndApps() {
554
587
  return new DetoxConfigError({
555
588
  message: `You can't have both "app" and "apps" defined in the ${J(this.configurationName)} configuration.`,
@@ -622,6 +655,20 @@ Examine your Detox config${this._atPath()}`,
622
655
  });
623
656
  }
624
657
 
658
+ invalidTestRunnerProperty(isGlobal) {
659
+ return new DetoxConfigError({
660
+ message: `testRunner should be an object, not a string`,
661
+ hint: `Check that in your Detox config${this._atPath()}`,
662
+ inspectOptions: { depth: isGlobal ? 0 : 3 },
663
+ debugInfo: isGlobal ? {
664
+ testRunner: _.get(this.contents, ['testRunner']),
665
+ ...this.contents,
666
+ } : {
667
+ ...this._focusOnConfiguration(c => _.pick(c, ['testRunner'])),
668
+ },
669
+ });
670
+ }
671
+
625
672
  cannotSkipAutostartWithMissingServer() {
626
673
  return new DetoxConfigError({
627
674
  message: `Cannot have both an undefined session.server URL and session.autoStart set to false`,
@@ -12,6 +12,10 @@ class DetoxError extends Error {
12
12
  return 'Please report this issue on our GitHub tracker:\nhttps://github.com/wix/Detox/issues';
13
13
  }
14
14
 
15
+ static get reportIssueIfJest() {
16
+ return `If you are using Detox with Jest according to the latest guide, ${_.lowerFirst(this.reportIssue)}`;
17
+ }
18
+
15
19
  static inspectObj(obj, options) {
16
20
  return util.inspect(obj, {
17
21
  colors: false,
@@ -4,23 +4,23 @@ const DetoxError = require('./DetoxError');
4
4
 
5
5
  /**
6
6
  * @typedef DetoxRuntimeErrorOptions
7
- * @property message { String }
7
+ * @property [message] { String }
8
8
  * @property [hint] { String }
9
- * @property [debugInfo] { String }
9
+ * @property [debugInfo] { * }
10
10
  * @property [noStack] { Boolean }
11
11
  * @property [inspectOptions] { Object }
12
12
  */
13
13
 
14
14
  class DetoxRuntimeError extends DetoxError {
15
15
  /**
16
- * @param options { DetoxRuntimeErrorOptions }
16
+ * @param [options] { String | DetoxRuntimeErrorOptions }
17
17
  */
18
18
  constructor(options) {
19
19
  super(formatOptions(options));
20
20
  this.name = 'DetoxRuntimeError';
21
21
 
22
- if (options && options.noStack) {
23
- delete this.stack;
22
+ if (options && typeof options !== 'string' && options.noStack) {
23
+ this.stack = '';
24
24
  }
25
25
  }
26
26
  }
@@ -1,4 +1,5 @@
1
1
  const DetoxConfigError = require('./DetoxConfigError');
2
+ const DetoxConfigErrorComposer = require('./DetoxConfigErrorComposer');
2
3
  const DetoxError = require('./DetoxError');
3
4
  const DetoxInternalError = require('./DetoxInternalError');
4
5
  const DetoxRuntimeError = require('./DetoxRuntimeError');
@@ -7,6 +8,7 @@ const DetoxRuntimeErrorComposer = require('./DetoxRuntimeErrorComposer');
7
8
  module.exports = {
8
9
  DetoxError,
9
10
  DetoxConfigError,
11
+ DetoxConfigErrorComposer,
10
12
  DetoxInternalError,
11
13
  DetoxRuntimeError,
12
14
  DetoxRuntimeErrorComposer,