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
@@ -0,0 +1,163 @@
1
+ const cp = require('child_process');
2
+
3
+ const _ = require('lodash');
4
+ const parser = require('yargs-parser');
5
+ const unparse = require('yargs-unparser');
6
+
7
+ const detox = require('../../internals');
8
+ const log = detox.log.child({ cat: ['lifecycle', 'cli'] });
9
+ const { DetoxRuntimeError } = require('../../src/errors');
10
+ const { printEnvironmentVariables, prependNodeModulesBinToPATH } = require('../../src/utils/envUtils');
11
+ const { escapeSpaces } = require('../../src/utils/shellUtils');
12
+
13
+ class TestRunnerCommand {
14
+ /*
15
+ @param {object} opts
16
+ @param {DetoxInternals.RuntimeConfig} opts.config
17
+ @param {ProcessEnv} opts.env
18
+ */
19
+ constructor(opts) {
20
+ const cliConfig = opts.config.cli;
21
+ const deviceConfig = opts.config.device;
22
+ const runnerConfig = opts.config.testRunner;
23
+
24
+ this._argv = runnerConfig.args;
25
+ this._retries = runnerConfig.retries;
26
+ this._envHint = this._buildEnvHint(opts.env);
27
+ this._envFwd = {};
28
+ if (runnerConfig.forwardEnv) {
29
+ this._envFwd = this._buildEnvOverride(cliConfig, deviceConfig);
30
+ Object.assign(this._envHint, this._envFwd);
31
+ }
32
+ }
33
+
34
+ async execute() {
35
+ let runsLeft = 1 + this._retries;
36
+ let launchError = null;
37
+
38
+ do {
39
+ try {
40
+ await this._spawnTestRunner();
41
+ launchError = null;
42
+ } catch (e) {
43
+ launchError = e;
44
+
45
+ const failedTestFiles = detox.session.testResults.filter(r => !r.success);
46
+
47
+ const { bail } = detox.config.testRunner;
48
+ if (bail && failedTestFiles.some(r => r.isPermanentFailure)) {
49
+ throw e;
50
+ }
51
+
52
+ const testFilesToRetry = failedTestFiles.filter(r => !r.isPermanentFailure).map(r => r.testFilePath);
53
+ if (_.isEmpty(testFilesToRetry)) {
54
+ throw e;
55
+ }
56
+
57
+ if (--runsLeft > 0) {
58
+ // @ts-ignore
59
+ detox.session.testSessionIndex++; // it is always the primary context, so we can update it
60
+ this._argv._ = testFilesToRetry;
61
+ this._logRelaunchError();
62
+ }
63
+ }
64
+ } while (launchError && runsLeft > 0);
65
+
66
+ if (launchError) {
67
+ throw launchError;
68
+ }
69
+ }
70
+
71
+ _buildEnvHint(env) {
72
+ return _(env)
73
+ .mapKeys((_value, key) => key.toUpperCase())
74
+ .pickBy((_value, key) => key.startsWith('DETOX_'))
75
+ .omit(['DETOX_CONFIG_SNAPSHOT_PATH'])
76
+ .value();
77
+ }
78
+
79
+ /**
80
+ * @param {DetoxInternals.CLIConfig} cliConfig
81
+ * @param {Detox.DetoxDeviceConfig} deviceConfig
82
+ */
83
+ _buildEnvOverride(cliConfig, deviceConfig) {
84
+ return _.omitBy({
85
+ DETOX_APP_LAUNCH_ARGS: cliConfig.appLaunchArgs,
86
+ DETOX_ARTIFACTS_LOCATION: cliConfig.artifactsLocation,
87
+ DETOX_CAPTURE_VIEW_HIERARCHY: cliConfig.captureViewHierarchy,
88
+ DETOX_CLEANUP: cliConfig.cleanup,
89
+ DETOX_CONFIGURATION: cliConfig.configuration,
90
+ DETOX_CONFIG_PATH: cliConfig.configPath,
91
+ DETOX_DEBUG_SYNCHRONIZATION: cliConfig.debugSynchronization,
92
+ DETOX_DEVICE_BOOT_ARGS: cliConfig.deviceBootArgs,
93
+ DETOX_DEVICE_NAME: cliConfig.deviceName,
94
+ DETOX_FORCE_ADB_INSTALL: deviceConfig.type.startsWith('android.')
95
+ ? cliConfig.forceAdbInstall
96
+ : undefined,
97
+ DETOX_GPU: cliConfig.gpu,
98
+ DETOX_HEADLESS: cliConfig.headless,
99
+ DETOX_KEEP_LOCKFILE: cliConfig.keepLockFile,
100
+ DETOX_LOGLEVEL: cliConfig.loglevel,
101
+ DETOX_READ_ONLY_EMU: cliConfig.readonlyEmu,
102
+ DETOX_RECORD_LOGS: cliConfig.recordLogs,
103
+ DETOX_RECORD_PERFORMANCE: cliConfig.recordPerformance,
104
+ DETOX_RECORD_VIDEOS: cliConfig.recordVideos,
105
+ DETOX_REPORT_SPECS: cliConfig.jestReportSpecs,
106
+ DETOX_RETRIES: cliConfig.retries,
107
+ DETOX_REUSE: cliConfig.reuse,
108
+ DETOX_TAKE_SCREENSHOTS: cliConfig.takeScreenshots,
109
+ DETOX_USE_CUSTOM_LOGGER: cliConfig.useCustomLogger,
110
+ }, _.isUndefined);
111
+ }
112
+
113
+ async _spawnTestRunner() {
114
+ const fullCommand = this._buildSpawnArguments().map(escapeSpaces);
115
+ const fullCommandWithHint = printEnvironmentVariables(this._envHint) + fullCommand.join(' ');
116
+
117
+ log.info({ env: this._envHint }, fullCommandWithHint);
118
+
119
+ return new Promise((resolve, reject) => {
120
+ cp.spawn(fullCommand[0], fullCommand.slice(1), {
121
+ shell: true,
122
+ stdio: 'inherit',
123
+ env: _({})
124
+ .assign(process.env)
125
+ .assign(this._envFwd)
126
+ .omitBy(_.isUndefined)
127
+ .tap(prependNodeModulesBinToPATH)
128
+ .value()
129
+ })
130
+ .on('error', /* istanbul ignore next */ (err) => reject(err))
131
+ .on('exit', (code) => code === 0
132
+ ? resolve()
133
+ : reject(new DetoxRuntimeError(`Command failed with exit code = ${code}:\n${fullCommandWithHint}`)
134
+ ));
135
+ });
136
+ }
137
+
138
+ _buildSpawnArguments() {
139
+ /* istanbul ignore next */
140
+ const { _: specs = [], '--': passthrough = [], $0, ...argv } = this._argv;
141
+ const { _: $0_, ...$0argv } = parser($0);
142
+
143
+ return [
144
+ ...$0_,
145
+ ...unparse($0argv),
146
+ ...unparse(argv),
147
+ ...unparse({ _: [...passthrough, ...specs] }),
148
+ ].map(String);
149
+ }
150
+
151
+ _logRelaunchError() {
152
+ const list = this._argv._.map((file, index) => {
153
+ return ` ${index + 1}. ${file}`;
154
+ }).join('\n');
155
+
156
+ log.error(
157
+ `There were failing tests in the following files:\n${list}\n\n` +
158
+ 'Detox CLI is going to restart the test runner with those files...\n'
159
+ );
160
+ }
161
+ }
162
+
163
+ module.exports = TestRunnerCommand;
@@ -10,27 +10,17 @@ module.exports = {
10
10
  describe:
11
11
  'Select a device configuration from your defined configurations, if not supplied, and there\'s only one configuration, detox will default to it',
12
12
  },
13
- o: {
14
- alias: 'runner-config',
15
- group: 'Configuration:',
16
- describe: 'Test runner config file, defaults to e2e/mocha.opts for mocha and e2e/config.json for jest',
17
- },
18
13
  l: {
19
14
  alias: 'loglevel',
20
15
  group: 'Debugging:',
21
- choices: ['fatal', 'error', 'warn', 'info', 'verbose', 'trace'],
16
+ choices: ['fatal', 'error', 'warn', 'info', 'verbose', 'debug', 'trace'],
22
17
  describe: 'Log level',
23
18
  },
24
- 'no-color': {
25
- describe: 'Disable colors in log output',
26
- boolean: true,
27
- },
28
19
  R: {
29
20
  alias: 'retries',
30
21
  group: 'Execution:',
31
- describe: '[Jest Circus Only] Re-spawn the test runner for individual failing suite files until they pass, or <N> times at least.',
22
+ describe: 'Re-spawn the test runner for individual failing suite files until they pass, or <N> times at least.',
32
23
  number: true,
33
- default: 0,
34
24
  },
35
25
  r: {
36
26
  alias: 'reuse',
@@ -48,10 +38,6 @@ module.exports = {
48
38
  alias: 'debug-synchronization',
49
39
  group: 'Debugging:',
50
40
  coerce(value) {
51
- if (value == null) {
52
- return undefined;
53
- }
54
-
55
41
  if (value === false || value === 'false') {
56
42
  return 0;
57
43
  }
@@ -96,33 +82,23 @@ module.exports = {
96
82
  choices: ['enabled', 'disabled'],
97
83
  describe: '[iOS Only] Capture *.uihierarchy snapshots on view action errors and device.captureViewHierarchy() calls.',
98
84
  },
99
- 'record-timeline': {
100
- group: 'Debugging:',
101
- choices: ['all', 'none'],
102
- describe: '[Jest Only] Record tests and events timeline, for visual display on the chrome://tracing tool.',
103
- },
104
- w: {
105
- alias: 'workers',
106
- group: 'Execution:',
107
- describe: 'Specifies the number of workers the test runner should spawn. Requires a test runner with parallel execution support (e.g. Jest)',
108
- number: true,
109
- },
110
85
  'jest-report-specs': {
111
86
  group: 'Execution:',
112
- describe: '[Jest Only] Whether to output logs per each running spec, in real-time. By default, disabled with multiple workers.',
87
+ describe: 'Whether to output logs per each running spec, in real-time. By default, disabled with multiple workers.',
113
88
  boolean: true,
114
89
  },
115
90
  H: {
116
91
  alias: 'headless',
117
92
  group: 'Execution:',
118
- describe: '[Android Only] Launch emulator in headless mode. Useful when running on CI. Only applicable for Google emulators.',
93
+ describe: 'Launch device in headless mode. Useful when running on CI.',
119
94
  boolean: true,
120
95
  },
121
96
  gpu: {
122
97
  group: 'Execution:',
123
- describe: '[Android Only] Launch emulator with the specific -gpu [gpu mode] parameter. Only applicable for Google emulators.',
98
+ choices: ['auto', 'host', 'swiftshader_indirect', 'angle_indirect', 'guest', 'off'],
99
+ describe: '[Android Only] Launch emulator with the specific -gpu [gpu mode] parameter.',
124
100
  },
125
- keepLockFile:{
101
+ keepLockFile: {
126
102
  group: 'Configuration:',
127
103
  describe:'Keep the device lock file when running Detox tests',
128
104
  boolean: true,
@@ -133,7 +109,6 @@ module.exports = {
133
109
  describe: 'Override the device name specified in a configuration. Useful for running a single build configuration on multiple devices.',
134
110
  },
135
111
  'device-boot-args': {
136
- alias: 'device-launch-args',
137
112
  group: 'Execution:',
138
113
  describe: 'Custom arguments to pass (through) onto the device (emulator/simulator) binary when booted.',
139
114
  },
@@ -143,18 +118,17 @@ module.exports = {
143
118
  },
144
119
  'use-custom-logger': {
145
120
  boolean: true,
146
- default: true,
147
121
  group: 'Execution:',
148
- describe: `Use Detox' custom console-logging implementation, for logging Detox (non-device) logs. Disabling will fallback to node.js / test-runner's implementation (e.g. Jest / Mocha).`,
122
+ describe: `Use Detox' custom console-logging implementation, for logging Detox (non-device) logs. Disabling will fallback to node.js / test runner's implementation (e.g. Jest).`,
149
123
  },
150
124
  'force-adb-install': {
151
125
  boolean: true,
152
126
  group: 'Execution:',
153
- describe: `Due to problems with the "adb install" command on Android, Detox resorts to a different scheme for install APK's. Setting true will disable that and force usage of "adb install", instead.`,
127
+ describe: `[Android Only] Due to problems with the "adb install" command on Android, Detox resorts to a different scheme for install APK's. Setting true will disable that and force usage of "adb install", instead.`,
154
128
  },
155
129
  'inspect-brk': {
156
130
  group: 'Debugging:',
157
- describe: 'Allows debugging of the underlying test runner',
131
+ describe: '[Jest Only] Allows debugging of the underlying test runner',
158
132
  boolean: true,
159
133
  }
160
134
  };
@@ -0,0 +1,66 @@
1
+ const _ = require('lodash');
2
+
3
+ const { log } = require('../../internals');
4
+ const { getJestBooleanArgs } = require('../utils/jestInternals');
5
+ const { simpleUnquote, extractKnownKeys, disengageBooleanArgs } = require('../utils/yargsUtils');
6
+
7
+ const testCommandArgs = require('./builder');
8
+ const { DETOX_ARGV_OVERRIDE_NOTICE } = require('./warnings');
9
+
10
+ function applyEnvironmentVariableAddendum(argv, yargs) {
11
+ if (process.env.DETOX_ARGV_OVERRIDE) {
12
+ log.warn(DETOX_ARGV_OVERRIDE_NOTICE);
13
+
14
+ const { _: positional, '--': passthrough, ...named } = yargs.parse(process.env.DETOX_ARGV_OVERRIDE);
15
+
16
+ if (!_.isEmpty(positional)) {
17
+ /* istanbul ignore next */
18
+ argv._ = argv._ || [];
19
+ argv._.push(...positional.map(simpleUnquote));
20
+ }
21
+
22
+ if (!_.isEmpty(passthrough)) {
23
+ argv['--'] = argv['--'] || [];
24
+ argv['--'].push(...passthrough.map(simpleUnquote));
25
+ }
26
+
27
+ Object.assign(argv, named);
28
+ }
29
+
30
+ return argv;
31
+ }
32
+
33
+ /**
34
+ * @param {Record<string, *>} argv
35
+ * @returns {{
36
+ * detoxArgs: Record<string, *>,
37
+ * runnerArgs: Record<string, *>
38
+ * }}
39
+ */
40
+ function splitArgv(argv) {
41
+ const aliases = extractKnownKeys(testCommandArgs);
42
+ const isDetoxArg = (_value, key) => key === '$0' || aliases.has(key);
43
+
44
+ const detoxArgs = _.pickBy(argv, isDetoxArg);
45
+ const runnerArgv = _.omitBy(argv, isDetoxArg);
46
+ runnerArgv._ = runnerArgv._.slice(1); // omit 'test' string, as in 'detox test'
47
+ if (typeof detoxArgs['debug-synchronization'] === 'string') {
48
+ const erroneousPassthrough = detoxArgs['debug-synchronization'];
49
+ detoxArgs['debug-synchronization'] = 3000;
50
+ runnerArgv._.unshift(erroneousPassthrough);
51
+ }
52
+
53
+ const runnerArgs = disengageBooleanArgs(runnerArgv, getJestBooleanArgs());
54
+ return { detoxArgs, runnerArgs };
55
+ }
56
+
57
+ // noinspection JSUnusedGlobalSymbols
58
+ module.exports = {
59
+ applyEnvironmentVariableAddendum,
60
+ splitArgv,
61
+ };
62
+
63
+ module.exports.default = [
64
+ applyEnvironmentVariableAddendum,
65
+ splitArgv,
66
+ ];
@@ -1,14 +1,3 @@
1
- const { DEVICE_LAUNCH_ARGS_DEPRECATION } = require('../../src/configuration/utils/warnings');
2
- const log = require('../../src/utils/logger').child({ __filename });
3
-
4
- function coerceDeprecation(option) {
5
- return function coerceDeprecationFn(value) {
6
- log.warn(`Beware: ${option} will be removed in the next version of Detox.`);
7
-
8
- return value;
9
- };
10
- }
11
-
12
1
  const DETOX_ARGV_OVERRIDE_NOTICE = `
13
2
  _____ _____ ___________
14
3
  / ___|_ _| _ | ___ \\ $DETOX_ARGV_OVERRIDE is detected
@@ -30,7 +19,5 @@ const DETOX_ARGV_OVERRIDE_NOTICE = `
30
19
  `;
31
20
 
32
21
  module.exports = {
33
- coerceDeprecation,
34
22
  DETOX_ARGV_OVERRIDE_NOTICE,
35
- DEVICE_LAUNCH_ARGS_DEPRECATION,
36
23
  };
@@ -2,10 +2,13 @@
2
2
  const Module = require('module');
3
3
  const path = require('path');
4
4
 
5
+ const _ = require('lodash');
5
6
  const resolveFrom = require('resolve-from');
6
7
  const semver = require('semver');
7
8
 
8
- const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');
9
+ const { DetoxRuntimeError } = require('../../src/errors');
10
+
11
+ const { extractKnownKeys } = require('./yargsUtils');
9
12
 
10
13
  const getNodeModulePaths = (dir) => Module._nodeModulePaths(dir);
11
14
 
@@ -68,7 +71,15 @@ async function readJestConfig(argv) {
68
71
  return readConfig(argv, process.cwd(), false);
69
72
  }
70
73
 
74
+ function getJestBooleanArgs() {
75
+ return _(resolveJestCliArgs())
76
+ .thru(args => args.options)
77
+ .pickBy(({ type }) => type === 'boolean')
78
+ .thru(extractKnownKeys)
79
+ .value();
80
+ }
81
+
71
82
  module.exports = {
72
- resolveJestCliArgs,
83
+ getJestBooleanArgs,
73
84
  readJestConfig,
74
85
  };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @param {Record<string, Record<string, *>>} yargsBuilder
3
+ * @returns {Set<string>}
4
+ */
5
+ function extractKnownKeys(yargsBuilder) {
6
+ return Object.entries(yargsBuilder).reduce(
7
+ (set, [key, option]) => {
8
+ if (option.alias) {
9
+ if (Array.isArray(option.alias)) {
10
+ for (const value of option.alias) {
11
+ set.add(value);
12
+ }
13
+ } else {
14
+ set.add(option.alias);
15
+ }
16
+ }
17
+
18
+ return set.add(key);
19
+ },
20
+ new Set()
21
+ );
22
+ }
23
+
24
+ /**
25
+ * @param {Record<string, *>} argv
26
+ * @param {Set<string>} booleanKeys
27
+ * @returns {Record<string, *>}
28
+ */
29
+ function disengageBooleanArgs(argv, booleanKeys) {
30
+ const result = {};
31
+ const passthrough = [];
32
+
33
+ for (const entry of Object.entries(argv)) {
34
+ const [key, value] = entry;
35
+ if (key === '_' || key === '--') {
36
+ continue;
37
+ }
38
+
39
+ const positiveKey = key.startsWith('no-') ? key.slice(3) : key;
40
+ if (booleanKeys.has(positiveKey) && typeof value !== 'boolean') {
41
+ result[positiveKey] = key === positiveKey;
42
+ passthrough.push(value);
43
+ } else {
44
+ result[key] = value;
45
+ }
46
+ }
47
+
48
+ return {
49
+ ...result,
50
+ '_': passthrough.concat(argv._),
51
+ '--': argv['--'] || [],
52
+ };
53
+ }
54
+
55
+ function simpleUnquote(arg) {
56
+ if ((arg[0] === '"' || arg[0] === "'") && arg[0] === arg[arg.length - 1]) {
57
+ return arg.slice(1, -1);
58
+ }
59
+
60
+ return arg;
61
+ }
62
+
63
+ module.exports = {
64
+ disengageBooleanArgs,
65
+ extractKnownKeys,
66
+ simpleUnquote,
67
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "detox",
3
3
  "description": "E2E tests and automation for mobile",
4
- "version": "19.13.0",
4
+ "version": "20.0.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/wix/Detox/issues"
15
15
  },
16
16
  "homepage": "https://github.com/wix/Detox#readme",
17
- "main": "./src/index.js",
17
+ "main": "./index.js",
18
18
  "types": "./index.d.ts",
19
19
  "author": "Tal Kol <talkol@gmail.com>",
20
20
  "license": "MIT",
@@ -32,9 +32,12 @@
32
32
  "postinstall": "node scripts/postinstall.js"
33
33
  },
34
34
  "devDependencies": {
35
+ "@types/bunyan": "^1.8.8",
35
36
  "@types/child-process-promise": "^2.2.1",
36
- "@types/jest": "^27.0.3",
37
- "@types/node": "^12.20.37",
37
+ "@types/fs-extra": "^9.0.13",
38
+ "@types/jest": "^28.1.8",
39
+ "@types/node": "^14.18.33",
40
+ "@types/node-ipc": "^9.2.0",
38
41
  "@types/ws": "^7.4.0",
39
42
  "@typescript-eslint/eslint-plugin": "^5.4.0",
40
43
  "@typescript-eslint/parser": "^5.4.0",
@@ -43,8 +46,7 @@
43
46
  "eslint-plugin-no-only-tests": "^2.6.0",
44
47
  "eslint-plugin-node": "^11.1.0",
45
48
  "eslint-plugin-unicorn": "^39.0.0",
46
- "jest": "^28.0.0",
47
- "mocha": ">=6.0.0",
49
+ "jest": "^28.1.3",
48
50
  "mockdate": "^2.0.1",
49
51
  "prettier": "1.7.0",
50
52
  "react-native": "0.69.7",
@@ -55,15 +57,22 @@
55
57
  "dependencies": {
56
58
  "ajv": "^8.6.3",
57
59
  "bunyan": "^1.8.12",
58
- "bunyan-debug-stream": "^2.0.1",
60
+ "bunyan-debug-stream": "^3.1.0",
61
+ "caf": "^15.0.1",
59
62
  "chalk": "^2.4.2",
60
63
  "child-process-promise": "^2.2.0",
64
+ "duplexify": "^4.1.2",
61
65
  "find-up": "^4.1.0",
62
66
  "fs-extra": "^4.0.2",
63
67
  "funpermaproxy": "^1.0.1",
68
+ "glob": "^8.0.3",
64
69
  "ini": "^1.3.4",
70
+ "json-cycle": "^1.3.0",
65
71
  "lodash": "^4.17.5",
66
72
  "minimist": "^1.2.0",
73
+ "multi-sort-stream": "^1.0.3",
74
+ "multipipe": "^4.0.0",
75
+ "node-ipc": "^9.2.1",
67
76
  "proper-lockfile": "^3.0.2",
68
77
  "resolve-from": "^5.0.0",
69
78
  "sanitize-filename": "^1.6.1",
@@ -71,29 +80,28 @@
71
80
  "serialize-error": "^8.0.1",
72
81
  "shell-quote": "^1.7.2",
73
82
  "signal-exit": "^3.0.3",
83
+ "stream-json": "^1.7.4",
84
+ "strip-ansi": "^6.0.1",
74
85
  "tail": "^2.0.0",
75
86
  "telnet-client": "1.2.8",
76
87
  "tempfile": "^2.0.0",
88
+ "trace-event-lib": "^1.3.1",
77
89
  "which": "^1.3.1",
78
90
  "ws": "^7.0.0",
79
91
  "yargs": "^16.0.3",
80
- "yargs-parser": "^20.2.2",
92
+ "yargs-parser": "^20.2.9",
81
93
  "yargs-unparser": "^2.0.0"
82
94
  },
83
95
  "peerDependencies": {
84
- "jest": "26.0.x - 26.4.x || ^26.5.2 || 27.x.x || 28.x.x || 29.x.x",
85
- "mocha": ">=6.0.0"
96
+ "jest": "29.x.x || 28.x.x || ^27.2.5"
86
97
  },
87
98
  "peerDependenciesMeta": {
88
99
  "jest": {
89
100
  "optional": true
90
- },
91
- "mocha": {
92
- "optional": true
93
101
  }
94
102
  },
95
103
  "engines": {
96
- "node": ">=8.3.0"
104
+ "node": ">=14.5.0"
97
105
  },
98
106
  "jest": {
99
107
  "setupFiles": [
@@ -103,8 +111,9 @@
103
111
  "testRunner": "jest-circus/runner",
104
112
  "roots": [
105
113
  "node_modules",
114
+ "local-cli",
106
115
  "src",
107
- "local-cli"
116
+ "runners"
108
117
  ],
109
118
  "testPathIgnorePatterns": [
110
119
  "/node_modules/",
@@ -124,7 +133,6 @@
124
133
  "src/artifacts/screenshot",
125
134
  "src/artifacts/video",
126
135
  "src/devices/allocation/drivers/AllocationDriverBase.js",
127
- "src/devices/allocation/drivers/NoneAllocDriver.js",
128
136
  "src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js",
129
137
  "src/devices/allocation/drivers/android/emulator/patchAvdSkinConfig.js",
130
138
  "src/devices/allocation/drivers/ios",
@@ -145,14 +153,19 @@
145
153
  "src/validation/EnvironmentValidatorBase.js",
146
154
  "src/validation/factories",
147
155
  "src/validation/ios/IosSimulatorEnvValidator",
148
- "src/utils/MissingDetox.js",
149
156
  "src/utils/appdatapath.js",
150
157
  "src/utils/debug.js",
151
158
  "src/utils/environment.js",
152
159
  "src/utils/logger.js",
153
160
  "src/utils/pipeCommands.js",
154
161
  "src/utils/pressAnyKey.js",
155
- "src/utils/shellUtils.js"
162
+ "src/utils/shellUtils.js",
163
+ "runners/jest/reporters",
164
+ "runners/jest/testEnvironment",
165
+ "src/DetoxWorker.js",
166
+ "src/logger/utils/streamUtils.js",
167
+ "src/ipc",
168
+ "src/realms"
156
169
  ],
157
170
  "resetMocks": true,
158
171
  "resetModules": true,
@@ -177,5 +190,5 @@
177
190
  }
178
191
  }
179
192
  },
180
- "gitHead": "7e4d0112cfb404b9e93ac3a4a50a7e45909c1966"
193
+ "gitHead": "8c533cd0bbbd514071a31355516292a2cf3c89ce"
181
194
  }
@@ -0,0 +1,45 @@
1
+ const chalk = require('chalk');
2
+
3
+ // @ts-ignore
4
+ const bold = chalk.bold;
5
+
6
+ function getMaxWidth(text) {
7
+ const lines = text.split('\n');
8
+ return lines.reduce((acc, line) => Math.max(acc, line.length), 0);
9
+ }
10
+
11
+ function centerText(text, maxWidth = getMaxWidth(text)) {
12
+ return text
13
+ .split('\n')
14
+ .map(line => {
15
+ const padStart = Math.max(0, Math.floor((maxWidth - line.length) / 2));
16
+ const padEnd = Math.max(0, maxWidth - line.length - padStart);
17
+ return ' '.repeat(padStart) + line + ' '.repeat(padEnd);
18
+ })
19
+ .join('\n');
20
+ }
21
+
22
+ const header = `\
23
+ ========================= THE NEW JOURNEY BEGINS =============================`;
24
+
25
+ console.error(centerText(`\
26
+
27
+ ${bold(header)}
28
+
29
+ https://wix.github.io/Detox/docs/guide/migration
30
+
31
+ Sorry to say that Detox 20 comes without old adapters for Jest.
32
+ You have to rearrange your init code before you can continue your journey.
33
+
34
+ Navigate to the link and follow the migration guide steps.
35
+
36
+ Sincerely yours,
37
+ Detox team.
38
+
39
+ ${bold(header)}
40
+
41
+ `, header.length));
42
+
43
+ const error = new Error('\nPlease follow the migration guide:\nhttps://wix.github.io/Detox/docs/guide/migration\n\n');
44
+ error.stack = '';
45
+ throw error;