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
@@ -5,25 +5,16 @@ const WebSocket = require('ws');
5
5
  const DetoxInternalError = require('../errors/DetoxInternalError');
6
6
  const DetoxRuntimeError = require('../errors/DetoxRuntimeError');
7
7
  const Deferred = require('../utils/Deferred');
8
- const log = require('../utils/logger').child({ __filename });
8
+ const log = require('../utils/logger').child({ cat: 'ws-client,ws' });
9
9
 
10
10
  const InflightRequest = require('./InflightRequest');
11
11
 
12
- const EVENTS = {
13
- OPEN: Object.freeze({ event: 'WS_OPEN' }),
14
- ERROR: Object.freeze({ event: 'WS_ERROR' }),
15
- MESSAGE: Object.freeze({ event: 'WS_MESSAGE' }),
16
- SEND: Object.freeze({ event: 'WS_SEND' }),
17
- LATE_RESPONSE: Object.freeze({ event: 'WS_LATE_RESPONSE' }),
18
- };
19
-
20
12
  const DEFAULT_SEND_OPTIONS = {
21
13
  timeout: 0,
22
14
  };
23
15
 
24
16
  class AsyncWebSocket {
25
17
  constructor(url) {
26
- this._log = log.child({ url });
27
18
  this._url = url;
28
19
  this._ws = null;
29
20
  this._eventCallbacks = {};
@@ -99,9 +90,9 @@ class AsyncWebSocket {
99
90
 
100
91
  this.handleMultipleNonAtomicPendingActions();
101
92
 
102
- const messageAsString = JSON.stringify(message);
103
- this._log.trace(EVENTS.SEND, messageAsString);
104
- this._ws.send(messageAsString);
93
+ const payload = JSON.stringify(message);
94
+ log.trace({ data: payload }, 'send message');
95
+ this._ws.send(payload);
105
96
 
106
97
  return inFlight.promise;
107
98
  }
@@ -157,7 +148,7 @@ class AsyncWebSocket {
157
148
  }
158
149
 
159
150
  if (!hasPendingActions) {
160
- log.error(EVENTS.ERROR, DetoxRuntimeError.format(error));
151
+ log.error({ error });
161
152
  }
162
153
  }
163
154
 
@@ -186,7 +177,7 @@ class AsyncWebSocket {
186
177
  * @private
187
178
  */
188
179
  _onOpen(event) { // eslint-disable-line no-unused-vars
189
- this._log.trace(EVENTS.OPEN, `opened web socket to: ${this._url}`);
180
+ log.trace(`opened web socket to: ${this._url}`);
190
181
  this._opening.resolve();
191
182
  this._opening = null;
192
183
  }
@@ -234,7 +225,7 @@ class AsyncWebSocket {
234
225
  const data = event && event.data || null;
235
226
 
236
227
  try {
237
- this._log.trace(EVENTS.MESSAGE, data);
228
+ log.trace({ data }, 'get message');
238
229
 
239
230
  const json = JSON.parse(data);
240
231
  if (!json || !json.type) {
@@ -259,7 +250,7 @@ class AsyncWebSocket {
259
250
 
260
251
  if (!handled) {
261
252
  if (this._abortedMessageIds.has(json.messageId)) {
262
- log.debug(EVENTS.LATE_RESPONSE, `Received late response for messageId=${json.messageId}`);
253
+ log.debug({ messageId: json.messageId }, `late response`);
263
254
  } else {
264
255
  throw new DetoxRuntimeError('Unexpected message received over the web socket: ' + json.type);
265
256
  }
@@ -9,7 +9,7 @@ const DetoxRuntimeError = require('../errors/DetoxRuntimeError');
9
9
  const failedToReachTheApp = require('../errors/longreads/failedToReachTheApp');
10
10
  const Deferred = require('../utils/Deferred');
11
11
  const { asError, createErrorWithUserStack, replaceErrorStack } = require('../utils/errorUtils');
12
- const log = require('../utils/logger').child({ __filename });
12
+ const log = require('../utils/logger').child({ cat: 'ws-client,ws' });
13
13
 
14
14
  const AsyncWebSocket = require('./AsyncWebSocket');
15
15
  const actions = require('./actions/actions');
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  const { DetoxInternalError, DetoxRuntimeError } = require('../../errors');
3
- const { getDetoxLevel } = require('../../utils/logger');
3
+ const logger = require('../../utils/logger');
4
4
  const formatJSONStatus = require('../actions/formatters/SyncStatusFormatter');
5
5
 
6
6
  class Action {
@@ -201,7 +201,7 @@ class Invoke extends Action {
201
201
 
202
202
  if (response.params.viewHierarchy) {
203
203
  /* istanbul ignore next */
204
- if (/^(debug|trace)$/.test(getDetoxLevel())) {
204
+ if (/^(debug|trace)$/.test(logger.level)) {
205
205
  debugInfo = 'View Hierarchy:\n' + response.params.viewHierarchy;
206
206
  } else {
207
207
  hint = 'To print view hierarchy on failed actions/matches, use log-level verbose or higher.';
@@ -1,9 +1,6 @@
1
1
  const _ = require('lodash');
2
2
 
3
3
  const argparse = require('../utils/argparse');
4
- const log = require('../utils/logger').child({ __filename });
5
-
6
- const { DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION } = require('./utils/warnings');
7
4
 
8
5
  const asBoolean = (value) => {
9
6
  if (typeof value === 'boolean') {
@@ -25,18 +22,10 @@ const asNumber = (value) => {
25
22
  : undefined;
26
23
  };
27
24
 
28
- const deprecateDeviceLaunchArgs = (value) => {
29
- if (value) {
30
- log.warn(DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION);
31
- }
32
-
33
- return value;
34
- };
35
-
36
25
  function collectCliConfig({ argv }) {
37
26
  const env = (key) => argparse.getArgValue(key);
38
27
  const get = (key, fallback) => {
39
- const value = argv ? argv[key] : env(key);
28
+ const value = argv && Reflect.has(argv, key) ? argv[key] : env(key);
40
29
  return value === undefined ? fallback : value;
41
30
  };
42
31
 
@@ -47,12 +36,11 @@ function collectCliConfig({ argv }) {
47
36
  takeScreenshots: get('take-screenshots'),
48
37
  recordVideos: get('record-videos'),
49
38
  recordPerformance: get('record-performance'),
50
- recordTimeline: get('record-timeline'),
51
39
  cleanup: asBoolean(get('cleanup')),
52
40
  configPath: get('config-path'),
53
41
  configuration: get('configuration'),
54
42
  debugSynchronization: asNumber(get('debug-synchronization')),
55
- deviceBootArgs: get('device-boot-args', deprecateDeviceLaunchArgs(argparse.getEnvValue('device-launch-args'))),
43
+ deviceBootArgs: get('device-boot-args'),
56
44
  appLaunchArgs: get('app-launch-args'),
57
45
  deviceName: get('device-name'),
58
46
  forceAdbInstall: asBoolean(get('force-adb-install')),
@@ -64,9 +52,8 @@ function collectCliConfig({ argv }) {
64
52
  loglevel: get('loglevel'),
65
53
  noColor: asBoolean(get('no-color')),
66
54
  reuse: asBoolean(get('reuse')),
67
- runnerConfig: get('runner-config'),
68
55
  useCustomLogger: asBoolean(get('use-custom-logger')),
69
- workers: asNumber(get('workers')),
56
+ retries: asNumber(get('retries')),
70
57
  inspectBrk: asBoolean(get('inspect-brk')),
71
58
  }, _.isUndefined);
72
59
  }
@@ -19,12 +19,7 @@ const CLI_PARSER_OPTIONS = {
19
19
  * @returns {Record<string, Detox.DetoxAppConfig>}
20
20
  */
21
21
  function composeAppsConfig(opts) {
22
- const { localConfig } = opts;
23
-
24
- const appsConfig = localConfig.type
25
- ? composeAppsConfigFromPlain(opts)
26
- : composeAppsConfigFromAliased(opts);
27
-
22
+ const appsConfig = composeAppsConfigFromAliased(opts);
28
23
  overrideAppLaunchArgs(appsConfig, opts.cliConfig);
29
24
 
30
25
  return appsConfig;
@@ -35,65 +30,7 @@ function composeAppsConfig(opts) {
35
30
  * @param {string} opts.configurationName
36
31
  * @param {Detox.DetoxDeviceConfig} opts.deviceConfig
37
32
  * @param {Detox.DetoxConfig} opts.globalConfig
38
- * @param {Detox.DetoxPlainConfiguration} opts.localConfig
39
- * @returns {Record<string, Detox.DetoxAppConfig>}
40
- */
41
- function composeAppsConfigFromPlain(opts) {
42
- const { errorComposer, localConfig } = opts;
43
-
44
- if (localConfig.app || localConfig.apps) {
45
- throw errorComposer.oldSchemaHasAppAndApps();
46
- }
47
-
48
- /** @type {Detox.DetoxAppConfig} */
49
- let appConfig;
50
-
51
- switch (opts.deviceConfig.type) {
52
- case 'android.attached':
53
- case 'android.emulator':
54
- case 'android.genycloud':
55
- appConfig = {
56
- type: 'android.apk',
57
- binaryPath: localConfig.binaryPath,
58
- bundleId: localConfig.bundleId,
59
- build: localConfig.build,
60
- testBinaryPath: localConfig.testBinaryPath,
61
- launchArgs: localConfig.launchArgs,
62
- }; break;
63
- case 'ios.none':
64
- case 'ios.simulator':
65
- appConfig = {
66
- type: 'ios.app',
67
- binaryPath: localConfig.binaryPath,
68
- bundleId: localConfig.bundleId,
69
- build: localConfig.build,
70
- launchArgs: localConfig.launchArgs,
71
- };
72
- break;
73
- default:
74
- appConfig = {
75
- ...localConfig,
76
- };
77
- }
78
-
79
- validateAppConfig({
80
- errorComposer,
81
- appConfig,
82
- deviceConfig: opts.deviceConfig,
83
- appPath: ['configurations', opts.configurationName],
84
- });
85
-
86
- return {
87
- default: _.omitBy(appConfig, _.isUndefined),
88
- };
89
- }
90
-
91
- /**
92
- * @param {DetoxConfigErrorComposer} opts.errorComposer
93
- * @param {string} opts.configurationName
94
- * @param {Detox.DetoxDeviceConfig} opts.deviceConfig
95
- * @param {Detox.DetoxConfig} opts.globalConfig
96
- * @param {Detox.DetoxAliasedConfiguration} opts.localConfig
33
+ * @param {Detox.DetoxConfiguration} opts.localConfig
97
34
  * @returns {Record<string, Detox.DetoxAppConfig>}
98
35
  */
99
36
  function composeAppsConfigFromAliased(opts) {
@@ -101,8 +38,13 @@ function composeAppsConfigFromAliased(opts) {
101
38
  const result = {};
102
39
  const { configurationName, errorComposer, deviceConfig, globalConfig, localConfig } = opts;
103
40
 
41
+ const isBuiltinDevice = Boolean(deviceAppTypes[deviceConfig.type]);
104
42
  if (localConfig.app == null && localConfig.apps == null) {
105
- throw errorComposer.noAppIsDefined(deviceConfig.type);
43
+ if (isBuiltinDevice) {
44
+ throw errorComposer.noAppIsDefined(deviceConfig.type);
45
+ } else {
46
+ return result;
47
+ }
106
48
  }
107
49
 
108
50
  if (localConfig.app != null && localConfig.apps != null) {
@@ -202,6 +144,10 @@ function validateAppConfig({ appConfig, appPath, deviceConfig, errorComposer })
202
144
  if (appConfig.launchArgs && !_.isObject(appConfig.launchArgs)) {
203
145
  throw errorComposer.malformedAppLaunchArgs(appPath);
204
146
  }
147
+
148
+ if (appConfig.type !== 'android.apk' && appConfig.reversePorts) {
149
+ throw errorComposer.unsupportedReversePorts(appPath);
150
+ }
205
151
  }
206
152
 
207
153
  module.exports = composeAppsConfig;
@@ -4,18 +4,15 @@ const _ = require('lodash');
4
4
  const InstrumentsArtifactPlugin = require('../artifacts/instruments/InstrumentsArtifactPlugin');
5
5
  const LogArtifactPlugin = require('../artifacts/log/LogArtifactPlugin');
6
6
  const ScreenshotArtifactPlugin = require('../artifacts/screenshot/ScreenshotArtifactPlugin');
7
- const TimelineArtifactPlugin = require('../artifacts/timeline/TimelineArtifactPlugin');
8
7
  const IosUIHierarchyPlugin = require('../artifacts/uiHierarchy/IosUIHierarchyPlugin');
9
- const ArtifactPathBuilder = require('../artifacts/utils/ArtifactPathBuilder');
10
8
  const buildDefaultArtifactsRootDirpath = require('../artifacts/utils/buildDefaultArtifactsRootDirpath');
11
9
  const VideoArtifactPlugin = require('../artifacts/video/VideoArtifactPlugin');
12
- const resolveModuleFromPath = require('../utils/resolveModuleFromPath');
13
10
 
14
11
  /**
15
12
  * @param {*} cliConfig
16
13
  * @param {string} configurationName
17
14
  * @param {Detox.DetoxConfig} globalConfig
18
- * @param {Detox.DetoxConfigurationOverrides} localConfig
15
+ * @param {Detox.DetoxConfiguration} localConfig
19
16
  */
20
17
  function composeArtifactsConfig({
21
18
  cliConfig,
@@ -31,7 +28,6 @@ function composeArtifactsConfig({
31
28
  screenshot: cliConfig.takeScreenshots,
32
29
  video: cliConfig.recordVideos,
33
30
  instruments: cliConfig.recordPerformance,
34
- timeline: cliConfig.recordTimeline,
35
31
  uiHierarchy: cliConfig.captureViewHierarchy,
36
32
  },
37
33
  }),
@@ -40,13 +36,15 @@ function composeArtifactsConfig({
40
36
  extendArtifactsConfig(false),
41
37
  );
42
38
 
39
+ if (!artifactsConfig.pathBuilder) {
40
+ artifactsConfig.pathBuilder = undefined;
41
+ }
42
+
43
43
  artifactsConfig.rootDir = buildDefaultArtifactsRootDirpath(
44
44
  configurationName,
45
45
  artifactsConfig.rootDir
46
46
  );
47
47
 
48
- artifactsConfig.pathBuilder = resolveArtifactsPathBuilder(artifactsConfig);
49
-
50
48
  return artifactsConfig;
51
49
  }
52
50
 
@@ -54,13 +52,12 @@ function extendArtifactsConfig(config) {
54
52
  if (config === false) {
55
53
  return extendArtifactsConfig({
56
54
  rootDir: 'artifacts',
57
- pathBuilder: null,
55
+ pathBuilder: '',
58
56
  plugins: {
59
57
  log: 'none',
60
58
  screenshot: 'manual',
61
59
  video: 'none',
62
60
  instruments: 'none',
63
- timeline: 'none',
64
61
  uiHierarchy: 'disabled',
65
62
  },
66
63
  });
@@ -79,34 +76,11 @@ function extendArtifactsConfig(config) {
79
76
  screenshot: ifString(p.screenshot, ScreenshotArtifactPlugin.parseConfig),
80
77
  video: ifString(p.video, VideoArtifactPlugin.parseConfig),
81
78
  instruments: ifString(p.instruments, InstrumentsArtifactPlugin.parseConfig),
82
- timeline: ifString(p.timeline, TimelineArtifactPlugin.parseConfig),
83
79
  uiHierarchy: ifString(p.uiHierarchy, IosUIHierarchyPlugin.parseConfig),
84
80
  },
85
81
  };
86
82
  }
87
83
 
88
- function resolveArtifactsPathBuilder(artifactsConfig) {
89
- let { rootDir, pathBuilder } = artifactsConfig;
90
-
91
- if (typeof pathBuilder === 'string') {
92
- pathBuilder = resolveModuleFromPath(pathBuilder);
93
- }
94
-
95
- if (typeof pathBuilder === 'function') {
96
- try {
97
- pathBuilder = pathBuilder({ rootDir });
98
- } catch (e) {
99
- pathBuilder = new pathBuilder({ rootDir });
100
- }
101
- }
102
-
103
- if (!pathBuilder) {
104
- pathBuilder = new ArtifactPathBuilder({ rootDir });
105
- }
106
-
107
- return pathBuilder;
108
- }
109
-
110
84
  function ifString(value, mapper) {
111
85
  return typeof value === 'string' ? mapper(value) : value;
112
86
  }
@@ -4,36 +4,30 @@ const _ = require('lodash');
4
4
  /**
5
5
  * @param {*} cliConfig
6
6
  * @param {Detox.DetoxConfig} globalConfig
7
- * @param {Detox.DetoxConfigurationOverrides} localConfig
8
- * @param {Detox.DetoxInitOptions} userParams
7
+ * @param {Detox.DetoxConfiguration} localConfig
9
8
  */
10
9
  function composeBehaviorConfig({
11
10
  cliConfig,
12
11
  globalConfig,
13
12
  localConfig,
14
- userParams
15
13
  }) {
16
14
  return _.chain({})
17
15
  .defaultsDeep(
18
16
  {
19
17
  init: {
18
+ keepLockFile: cliConfig.keepLockFile ? true : undefined,
20
19
  reinstallApp: cliConfig.reuse ? false : undefined,
21
20
  },
22
21
  cleanup: {
23
22
  shutdownDevice: cliConfig.cleanup ? true : undefined,
24
23
  },
25
24
  },
26
- userParams && {
27
- init: {
28
- exposeGlobals: userParams.initGlobals,
29
- reinstallApp: negateDefined(userParams.reuse),
30
- },
31
- },
32
25
  localConfig.behavior,
33
26
  globalConfig.behavior,
34
27
  {
35
28
  init: {
36
29
  exposeGlobals: true,
30
+ keepLockFile: false,
37
31
  reinstallApp: undefined,
38
32
  },
39
33
  launchApp: 'auto',
@@ -50,8 +44,4 @@ function composeBehaviorConfig({
50
44
  .value();
51
45
  }
52
46
 
53
- function negateDefined(x) {
54
- return x !== undefined ? !x : undefined;
55
- }
56
-
57
47
  module.exports = composeBehaviorConfig;
@@ -2,7 +2,7 @@
2
2
  const _ = require('lodash');
3
3
 
4
4
  const environmentFactory = require('../environmentFactory');
5
- const log = require('../utils/logger').child({ __filename });
5
+ const log = require('../utils/logger').child({ cat: 'config' });
6
6
 
7
7
  /**
8
8
  * @param {DetoxConfigErrorComposer} opts.errorComposer
@@ -12,13 +12,8 @@ const log = require('../utils/logger').child({ __filename });
12
12
  * @returns {Detox.DetoxDeviceConfig}
13
13
  */
14
14
  function composeDeviceConfig(opts) {
15
- const { localConfig, cliConfig } = opts;
16
-
17
- const deviceConfig = localConfig.type
18
- ? composeDeviceConfigFromPlain(opts)
19
- : composeDeviceConfigFromAliased(opts);
20
-
21
- applyCLIOverrides(deviceConfig, cliConfig);
15
+ const deviceConfig = composeDeviceConfigFromAliased(opts);
16
+ applyCLIOverrides(deviceConfig, opts.cliConfig);
22
17
  deviceConfig.device = unpackDeviceQuery(deviceConfig);
23
18
 
24
19
  return deviceConfig;
@@ -27,29 +22,7 @@ function composeDeviceConfig(opts) {
27
22
  /**
28
23
  * @param {DetoxConfigErrorComposer} opts.errorComposer
29
24
  * @param {Detox.DetoxConfig} opts.globalConfig
30
- * @param {Detox.DetoxPlainConfiguration} opts.localConfig
31
- * @returns {Detox.DetoxDeviceConfig}
32
- */
33
- function composeDeviceConfigFromPlain(opts) {
34
- const { errorComposer, localConfig } = opts;
35
-
36
- const type = localConfig.type;
37
- const device = localConfig.device || localConfig.name;
38
- const utilBinaryPaths = localConfig.utilBinaryPaths;
39
-
40
- const deviceConfig = type in EXPECTED_DEVICE_MATCHER_PROPS
41
- ? _.omitBy({ type, device, utilBinaryPaths }, _.isUndefined)
42
- : { ...localConfig };
43
-
44
- validateDeviceConfig({ deviceConfig, errorComposer });
45
-
46
- return deviceConfig;
47
- }
48
-
49
- /**
50
- * @param {DetoxConfigErrorComposer} opts.errorComposer
51
- * @param {Detox.DetoxConfig} opts.globalConfig
52
- * @param {Detox.DetoxAliasedConfiguration} opts.localConfig
25
+ * @param {Detox.DetoxConfiguration} opts.localConfig
53
26
  * @returns {Detox.DetoxDeviceConfig}
54
27
  */
55
28
  function composeDeviceConfigFromAliased(opts) {
@@ -145,7 +118,7 @@ function validateDeviceConfig({ deviceConfig, errorComposer, deviceAlias }) {
145
118
  throw errorComposer.malformedDeviceProperty(deviceAlias, 'gpuMode');
146
119
  }
147
120
 
148
- if (!deviceConfig.gpuMode.match(/^(auto|host|swiftshader_indirect|angle_indirect|guest)$/)) {
121
+ if (!deviceConfig.gpuMode.match(/^(auto|host|swiftshader_indirect|angle_indirect|guest|off)$/)) {
149
122
  throw errorComposer.malformedDeviceProperty(deviceAlias, 'gpuMode');
150
123
  }
151
124
 
@@ -159,7 +132,7 @@ function validateDeviceConfig({ deviceConfig, errorComposer, deviceAlias }) {
159
132
  throw errorComposer.malformedDeviceProperty(deviceAlias, 'headless');
160
133
  }
161
134
 
162
- if (deviceConfig.type !== 'android.emulator') {
135
+ if (deviceConfig.type !== 'ios.simulator' && deviceConfig.type !== 'android.emulator') {
163
136
  throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'headless');
164
137
  }
165
138
  }
@@ -176,6 +149,7 @@ function validateDeviceConfig({ deviceConfig, errorComposer, deviceAlias }) {
176
149
 
177
150
  if (_.isObject(deviceConfig.device)) {
178
151
  const expectedProperties = EXPECTED_DEVICE_MATCHER_PROPS[deviceConfig.type];
152
+ /* istanbul ignore else */
179
153
  if (!_.isEmpty(expectedProperties)) {
180
154
  const minimalShape = _.pick(deviceConfig.device, expectedProperties);
181
155
 
@@ -187,41 +161,44 @@ function validateDeviceConfig({ deviceConfig, errorComposer, deviceAlias }) {
187
161
  }
188
162
 
189
163
  function applyCLIOverrides(deviceConfig, cliConfig) {
190
- if (cliConfig.deviceName) {
191
- deviceConfig.device = cliConfig.deviceName;
164
+ _assignCLIConfigIfSupported('device-name', cliConfig.deviceName, deviceConfig, 'device');
165
+ _assignCLIConfigIfSupported('device-boot-args', cliConfig.deviceBootArgs, deviceConfig, 'bootArgs');
166
+ _assignCLIConfigIfSupported('headless', cliConfig.headless, deviceConfig, 'headless');
167
+ _assignCLIConfigIfSupported('force-adb-install', cliConfig.forceAdbInstall, deviceConfig, 'forceAdbInstall');
168
+ _assignCLIConfigIfSupported('gpu', cliConfig.gpu, deviceConfig, 'gpuMode');
169
+ _assignCLIConfigIfSupported('readonly-emu', cliConfig.readonlyEmu, deviceConfig, 'readonly');
170
+ }
171
+
172
+ function _assignCLIConfigIfSupported(argName, argValue, deviceConfig, propertyName) {
173
+ if (argValue === undefined) {
174
+ return;
192
175
  }
193
176
 
194
177
  const deviceType = deviceConfig.type;
195
- if (cliConfig.deviceBootArgs) {
196
- if ((deviceType === 'ios.simulator') || (deviceType === 'android.emulator')) {
197
- deviceConfig.bootArgs = cliConfig.deviceBootArgs;
198
- } else {
199
- log.warn(`--device-boot-args CLI override is not supported by device type = "${deviceType}" and will be ignored`);
200
- }
178
+ const supportedDeviceTypesPrefixes = _supportedDeviceTypesPrefixes(argName);
179
+ if (!supportedDeviceTypesPrefixes.some((prefix) => deviceType.startsWith(prefix))) {
180
+ log.warn(`--${argName} CLI override is not supported by device type = "${deviceType}" and will be ignored`);
181
+ return;
201
182
  }
202
183
 
203
- if (cliConfig.forceAdbInstall !== undefined) {
204
- if (deviceType.startsWith('android.')) {
205
- deviceConfig.forceAdbInstall = cliConfig.forceAdbInstall;
206
- } else {
207
- log.warn(`--force-adb-install CLI override is not supported by device type = "${deviceType}" and will be ignored`);
208
- }
209
- }
184
+ deviceConfig[propertyName] = argValue;
185
+ }
210
186
 
211
- const emulatorCLIConfig = _.pick(cliConfig, ['headless', 'gpu', 'readonlyEmu']);
212
- const emulatorOverrides = _.omitBy({
213
- headless: cliConfig.headless,
214
- gpuMode: cliConfig.gpu,
215
- readonly: cliConfig.readonlyEmu,
216
- }, _.isUndefined);
187
+ function _supportedDeviceTypesPrefixes(argName) {
188
+ switch (argName) {
189
+ case 'device-name':
190
+ return [''];
217
191
 
218
- if (!_.isEmpty(emulatorOverrides)) {
219
- if (deviceType === 'android.emulator') {
220
- Object.assign(deviceConfig, emulatorOverrides);
221
- } else {
222
- const flags = Object.keys(emulatorCLIConfig).map(key => '--' + _.kebabCase(key)).join(', ');
223
- log.warn(`${flags} CLI overriding is not supported by device type = "${deviceType}" and will be ignored`);
224
- }
192
+ case 'force-adb-install':
193
+ return ['android.'];
194
+
195
+ case 'gpu':
196
+ case 'readonly-emu':
197
+ return ['android.emulator'];
198
+
199
+ case 'device-boot-args':
200
+ case 'headless':
201
+ return ['ios.simulator', 'android.emulator'];
225
202
  }
226
203
  }
227
204
 
@@ -232,7 +209,6 @@ function unpackDeviceQuery(deviceConfig) {
232
209
  }
233
210
 
234
211
  switch (deviceConfig.type) {
235
- case 'ios.none':
236
212
  case 'ios.simulator':
237
213
  if (_.includes(query, ',')) {
238
214
  const [type, os] = _.split(query, /\s*,\s*/);
@@ -252,7 +228,6 @@ function unpackDeviceQuery(deviceConfig) {
252
228
  }
253
229
 
254
230
  const EXPECTED_DEVICE_MATCHER_PROPS = {
255
- 'ios.none': null,
256
231
  'ios.simulator': ['type', 'name', 'id'],
257
232
  'android.attached': ['adbName'],
258
233
  'android.emulator': ['avdName'],
@@ -0,0 +1,59 @@
1
+ const _ = require('lodash');
2
+
3
+ const { castLevel, defaultOptions } = require('../logger/DetoxLogger');
4
+
5
+ /**
6
+ * @param {object} opts
7
+ * @param {Detox.DetoxConfig} opts.globalConfig
8
+ * @param {Detox.DetoxConfiguration} opts.localConfig
9
+ * @param {*} opts.cliConfig
10
+ */
11
+ function composeLoggerConfig(opts) {
12
+ const { globalConfig, localConfig, cliConfig } = opts;
13
+
14
+ const items = [
15
+ {
16
+ level: 'info',
17
+ overrideConsole: true,
18
+ options: defaultOptions,
19
+ },
20
+ globalConfig.logger,
21
+ localConfig.logger,
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')))
38
+ );
39
+ }
40
+
41
+ function adaptCLI(cliConfig) {
42
+ const result = {};
43
+
44
+ if (cliConfig.loglevel !== undefined) {
45
+ result.level = castLevel(cliConfig.loglevel);
46
+ }
47
+
48
+ if (cliConfig.useCustomLogger !== undefined) {
49
+ result.overrideConsole = cliConfig.useCustomLogger;
50
+ }
51
+
52
+ if (cliConfig.noColor) {
53
+ result.options = { colors: false };
54
+ }
55
+
56
+ return result;
57
+ }
58
+
59
+ module.exports = composeLoggerConfig;