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
@@ -0,0 +1,157 @@
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 { DetoxRuntimeError } = require('../../src/errors');
9
+ const { printEnvironmentVariables, prependNodeModulesBinToPATH } = require('../../src/utils/envUtils');
10
+ const { escapeSpaces } = require('../../src/utils/shellUtils');
11
+
12
+ class TestRunnerCommand {
13
+ constructor() {
14
+ this._argv = {};
15
+ this._env = {};
16
+ this._envHint = {};
17
+ this._retries = 0;
18
+ /** @type {Detox.DetoxDeviceConfig} */
19
+ this._deviceConfig = null;
20
+ }
21
+
22
+ /**
23
+ * @param {Detox.DetoxDeviceConfig} config
24
+ * @returns {this}
25
+ */
26
+ setDeviceConfig(config) {
27
+ this._deviceConfig = config;
28
+
29
+ return this;
30
+ }
31
+
32
+ /**
33
+ * @param {Detox.DetoxTestRunnerConfig} config
34
+ * @returns {this}
35
+ */
36
+ setRunnerConfig(config) {
37
+ this._argv = config.args;
38
+ this._retries = config.retries;
39
+
40
+ if (config.inspectBrk === true) {
41
+ this._env = this._envHint;
42
+ }
43
+
44
+ return this;
45
+ }
46
+
47
+ /**
48
+ * @param {Partial<Readonly<DetoxInternals.DetoxCLIConfig>>} cliConfig
49
+ * @returns {this}
50
+ */
51
+ replicateCLIConfig(cliConfig) {
52
+ this._envHint = _.omitBy({
53
+ DETOX_APP_LAUNCH_ARGS: cliConfig.appLaunchArgs,
54
+ DETOX_ARTIFACTS_LOCATION: cliConfig.artifactsLocation,
55
+ DETOX_CAPTURE_VIEW_HIERARCHY: cliConfig.captureViewHierarchy,
56
+ DETOX_CLEANUP: cliConfig.cleanup,
57
+ DETOX_CONFIGURATION: cliConfig.configuration,
58
+ DETOX_CONFIG_PATH: cliConfig.configPath,
59
+ DETOX_DEBUG_SYNCHRONIZATION: cliConfig.debugSynchronization,
60
+ DETOX_DEVICE_BOOT_ARGS: cliConfig.deviceBootArgs,
61
+ DETOX_DEVICE_NAME: cliConfig.deviceName,
62
+ DETOX_FORCE_ADB_INSTALL: this._deviceConfig.type.startsWith('android.')
63
+ ? cliConfig.forceAdbInstall
64
+ : undefined,
65
+ DETOX_GPU: cliConfig.gpu,
66
+ DETOX_HEADLESS: cliConfig.headless,
67
+ DETOX_KEEP_LOCKFILE: cliConfig.keepLockFile,
68
+ DETOX_LOGLEVEL: cliConfig.loglevel,
69
+ DETOX_READ_ONLY_EMU: cliConfig.readonlyEmu,
70
+ DETOX_RECORD_LOGS: cliConfig.recordLogs,
71
+ DETOX_RECORD_PERFORMANCE: cliConfig.recordPerformance,
72
+ DETOX_RECORD_VIDEOS: cliConfig.recordVideos,
73
+ DETOX_REPORT_SPECS: cliConfig.jestReportSpecs,
74
+ DETOX_RETRIES: cliConfig.retries,
75
+ DETOX_REUSE: cliConfig.reuse,
76
+ DETOX_TAKE_SCREENSHOTS: cliConfig.takeScreenshots,
77
+ DETOX_USE_CUSTOM_LOGGER: cliConfig.useCustomLogger,
78
+ }, _.isUndefined);
79
+
80
+ return this;
81
+ }
82
+
83
+ async execute() {
84
+ let runsLeft = 1 + this._retries;
85
+ let launchError;
86
+
87
+ do {
88
+ try {
89
+ if (launchError) {
90
+ const list = this._argv._.map((file, index) => ` ${index + 1}. ${file}`).join('\n');
91
+ detox.log.error(
92
+ `There were failing tests in the following files:\n${list}\n\n` +
93
+ 'Detox CLI is going to restart the test runner with those files...\n'
94
+ );
95
+ }
96
+
97
+ await this._doExecute();
98
+ launchError = null;
99
+ } catch (e) {
100
+ launchError = e;
101
+
102
+ // @ts-ignore
103
+ const { failedTestFiles } = detox.session;
104
+ if (_.isEmpty(failedTestFiles)) {
105
+ throw e;
106
+ }
107
+
108
+ this._argv._ = failedTestFiles.slice();
109
+ this._env.DETOX_RERUN_INDEX = 1 + (this._env.DETOX_RERUN_INDEX || 0);
110
+ failedTestFiles.splice(0, Infinity);
111
+ }
112
+ } while (launchError && --runsLeft > 0);
113
+
114
+ if (launchError) {
115
+ throw launchError;
116
+ }
117
+ }
118
+
119
+ async _doExecute() {
120
+ const fullCommand = this._buildSpawnArguments().map(escapeSpaces);
121
+ const fullCommandWithHint = printEnvironmentVariables(this._envHint) + fullCommand.join(' ');
122
+
123
+ detox.log.info({ event: 'RUN_START', env: this._envHint }, fullCommandWithHint);
124
+
125
+ return new Promise((resolve, reject) => {
126
+ cp.spawn(fullCommand[0], fullCommand.slice(1), {
127
+ shell: true,
128
+ stdio: 'inherit',
129
+ env: _({})
130
+ .assign(process.env)
131
+ .assign(this._env)
132
+ .omitBy(_.isUndefined)
133
+ .tap(prependNodeModulesBinToPATH)
134
+ .value()
135
+ })
136
+ .on('error', (err) => reject(err))
137
+ .on('exit', (code) => code === 0
138
+ ? resolve()
139
+ : reject(new DetoxRuntimeError(`Command failed with exit code = ${code}:\n${fullCommandWithHint}`)
140
+ ));
141
+ });
142
+ }
143
+
144
+ _buildSpawnArguments() {
145
+ const { _: specs = [], '--': passthrough = [], $0, ...argv } = this._argv;
146
+ const { _: $0_, ...$0argv } = parser($0);
147
+
148
+ return [
149
+ ...$0_,
150
+ ...unparse($0argv),
151
+ ...unparse(argv),
152
+ ...unparse({ _: [...passthrough, ...specs] }),
153
+ ].map(String);
154
+ }
155
+ }
156
+
157
+ 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,
@@ -143,18 +119,17 @@ module.exports = {
143
119
  },
144
120
  'use-custom-logger': {
145
121
  boolean: true,
146
- default: true,
147
122
  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).`,
123
+ 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
124
  },
150
125
  'force-adb-install': {
151
126
  boolean: true,
152
127
  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.`,
128
+ 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
129
  },
155
130
  'inspect-brk': {
156
131
  group: 'Debugging:',
157
- describe: 'Allows debugging of the underlying test runner',
132
+ describe: '[Jest Only] Allows debugging of the underlying test runner',
158
133
  boolean: true,
159
134
  }
160
135
  };
@@ -0,0 +1,75 @@
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, DEVICE_LAUNCH_ARGS_DEPRECATION } = 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 (positional) {
17
+ argv._ = argv._ || [];
18
+ argv._.push(...positional.map(simpleUnquote));
19
+ }
20
+
21
+ if (passthrough) {
22
+ argv['--'] = argv['--'] || [];
23
+ argv['--'].push(...passthrough.map(simpleUnquote));
24
+ }
25
+
26
+ Object.assign(argv, named);
27
+ }
28
+
29
+ return argv;
30
+ }
31
+
32
+ function warnDeviceAppLaunchArgsDeprecation(argv) {
33
+ if (argv['device-boot-args'] && process.argv.some(a => a.startsWith('--device-launch-args'))) {
34
+ log.warn(DEVICE_LAUNCH_ARGS_DEPRECATION);
35
+ }
36
+
37
+ return argv;
38
+ }
39
+
40
+ /**
41
+ * @param {Record<string, *>} argv
42
+ * @returns {{
43
+ * detoxArgs: Record<string, *>,
44
+ * runnerArgs: Record<string, *>
45
+ * }}
46
+ */
47
+ function splitArgv(argv) {
48
+ const aliases = extractKnownKeys(testCommandArgs);
49
+ const isDetoxArg = (_value, key) => key === '$0' || aliases.has(key);
50
+
51
+ const detoxArgs = _.pickBy(argv, isDetoxArg);
52
+ const runnerArgv = _.omitBy(argv, isDetoxArg);
53
+ runnerArgv._ = runnerArgv._.slice(1); // omit 'test' string, as in 'detox test'
54
+ if (typeof detoxArgs['debug-synchronization'] === 'string') {
55
+ const erroneousPassthrough = detoxArgs['debug-synchronization'];
56
+ detoxArgs['debug-synchronization'] = 3000;
57
+ runnerArgv._.unshift(erroneousPassthrough);
58
+ }
59
+
60
+ const runnerArgs = disengageBooleanArgs(runnerArgv, getJestBooleanArgs());
61
+ return { detoxArgs, runnerArgs };
62
+ }
63
+
64
+ // noinspection JSUnusedGlobalSymbols
65
+ module.exports = {
66
+ applyEnvironmentVariableAddendum,
67
+ warnDeviceAppLaunchArgsDeprecation,
68
+ splitArgv,
69
+ };
70
+
71
+ module.exports.default = [
72
+ applyEnvironmentVariableAddendum,
73
+ warnDeviceAppLaunchArgsDeprecation,
74
+ splitArgv,
75
+ ];
@@ -1,13 +1,4 @@
1
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
2
 
12
3
  const DETOX_ARGV_OVERRIDE_NOTICE = `
13
4
  _____ _____ ___________
@@ -30,7 +21,6 @@ const DETOX_ARGV_OVERRIDE_NOTICE = `
30
21
  `;
31
22
 
32
23
  module.exports = {
33
- coerceDeprecation,
34
24
  DETOX_ARGV_OVERRIDE_NOTICE,
35
25
  DEVICE_LAUNCH_ARGS_DEPRECATION,
36
26
  };
@@ -2,9 +2,12 @@
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
 
7
- const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');
8
+ const { DetoxRuntimeError } = require('../../src/errors');
9
+
10
+ const { extractKnownKeys } = require('./yargsUtils');
8
11
 
9
12
  const getNodeModulePaths = (dir) => Module._nodeModulePaths(dir);
10
13
 
@@ -65,7 +68,15 @@ async function readJestConfig(argv) {
65
68
  return readConfig(argv, process.cwd(), false);
66
69
  }
67
70
 
71
+ function getJestBooleanArgs() {
72
+ return _(resolveJestCliArgs())
73
+ .thru(args => args.options)
74
+ .pickBy(({ type }) => type === 'boolean')
75
+ .thru(extractKnownKeys)
76
+ .value();
77
+ }
78
+
68
79
  module.exports = {
69
- resolveJestCliArgs,
80
+ getJestBooleanArgs,
70
81
  readJestConfig,
71
82
  };
@@ -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.9.0",
4
+ "version": "21.0.0-breaking.new-global-lifecycle.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",
37
+ "@types/fs-extra": "^9.0.13",
36
38
  "@types/jest": "^27.0.3",
37
39
  "@types/node": "^12.20.37",
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,11 +46,10 @@
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": "^27.5.1",
48
50
  "mockdate": "^2.0.1",
49
51
  "prettier": "1.7.0",
50
- "react-native": "0.68.2",
52
+ "react-native": "0.67.2",
51
53
  "react-native-codegen": "^0.0.8",
52
54
  "typescript": "^4.5.2",
53
55
  "wtfnode": "^0.9.1"
@@ -55,15 +57,20 @@
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.0.2",
59
61
  "chalk": "^2.4.2",
60
62
  "child-process-promise": "^2.2.0",
63
+ "duplexify": "^4.1.2",
61
64
  "find-up": "^4.1.0",
62
65
  "fs-extra": "^4.0.2",
63
66
  "funpermaproxy": "^1.0.1",
64
67
  "ini": "^1.3.4",
68
+ "json-cycle": "^1.3.0",
65
69
  "lodash": "^4.17.5",
66
70
  "minimist": "^1.2.0",
71
+ "multi-sort-stream": "^1.0.3",
72
+ "multipipe": "^4.0.0",
73
+ "node-ipc": "^9.2.1",
67
74
  "proper-lockfile": "^3.0.2",
68
75
  "resolve-from": "^5.0.0",
69
76
  "sanitize-filename": "^1.6.1",
@@ -71,29 +78,28 @@
71
78
  "serialize-error": "^8.0.1",
72
79
  "shell-quote": "^1.7.2",
73
80
  "signal-exit": "^3.0.3",
81
+ "stream-json": "^1.7.4",
82
+ "strip-ansi": "^6.0.1",
74
83
  "tail": "^2.0.0",
75
84
  "telnet-client": "1.2.8",
76
85
  "tempfile": "^2.0.0",
86
+ "trace-event-lib": "^1.1.0",
77
87
  "which": "^1.3.1",
78
88
  "ws": "^7.0.0",
79
89
  "yargs": "^16.0.3",
80
- "yargs-parser": "^20.2.2",
90
+ "yargs-parser": "^20.2.9",
81
91
  "yargs-unparser": "^2.0.0"
82
92
  },
83
93
  "peerDependencies": {
84
- "jest": "26.0.x - 26.4.x || ^26.5.2 || 27.x.x || 28.x.x",
85
- "mocha": ">=6.0.0"
94
+ "jest": "28.x.x || ^27.2.5"
86
95
  },
87
96
  "peerDependenciesMeta": {
88
97
  "jest": {
89
98
  "optional": true
90
- },
91
- "mocha": {
92
- "optional": true
93
99
  }
94
100
  },
95
101
  "engines": {
96
- "node": ">=8.3.0"
102
+ "node": ">=12.10.0"
97
103
  },
98
104
  "jest": {
99
105
  "setupFiles": [
@@ -103,8 +109,9 @@
103
109
  "testRunner": "jest-circus/runner",
104
110
  "roots": [
105
111
  "node_modules",
112
+ "local-cli",
106
113
  "src",
107
- "local-cli"
114
+ "runners"
108
115
  ],
109
116
  "testPathIgnorePatterns": [
110
117
  "/node_modules/",
@@ -124,7 +131,6 @@
124
131
  "src/artifacts/screenshot",
125
132
  "src/artifacts/video",
126
133
  "src/devices/allocation/drivers/AllocationDriverBase.js",
127
- "src/devices/allocation/drivers/NoneAllocDriver.js",
128
134
  "src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js",
129
135
  "src/devices/allocation/drivers/android/emulator/patchAvdSkinConfig.js",
130
136
  "src/devices/allocation/drivers/ios",
@@ -145,14 +151,14 @@
145
151
  "src/validation/EnvironmentValidatorBase.js",
146
152
  "src/validation/factories",
147
153
  "src/validation/ios/IosSimulatorEnvValidator",
148
- "src/utils/MissingDetox.js",
149
154
  "src/utils/appdatapath.js",
150
155
  "src/utils/debug.js",
151
156
  "src/utils/environment.js",
152
157
  "src/utils/logger.js",
153
158
  "src/utils/pipeCommands.js",
154
159
  "src/utils/pressAnyKey.js",
155
- "src/utils/shellUtils.js"
160
+ "src/utils/shellUtils.js",
161
+ "runners/jest/.*.js"
156
162
  ],
157
163
  "resetMocks": true,
158
164
  "resetModules": true,
@@ -170,12 +176,12 @@
170
176
  ],
171
177
  "coverageThreshold": {
172
178
  "global": {
173
- "statements": 100,
174
- "branches": 100,
175
- "functions": 100,
176
- "lines": 100
179
+ "statements": 0,
180
+ "branches": 0,
181
+ "functions": 0,
182
+ "lines": 0
177
183
  }
178
184
  }
179
185
  },
180
- "gitHead": "22290ba2b9d687065925ceada77daa460331689e"
186
+ "gitHead": "5c9f55d001261c12376998bce4d3221540a52cc4"
181
187
  }
@@ -0,0 +1,47 @@
1
+ const chalk = require('chalk');
2
+
3
+ // @ts-ignore
4
+ console.error(chalk.yellow(`
5
+ ========================= THE NEW JOURNEY BEGINS =============================
6
+
7
+ https://github.com/wix/Detox/blob/master/docs/Guide.Jest.md
8
+
9
+ _.-;-._ Sorry, traveler from the lands of Detox 19!
10
+ ;_.JL___;
11
+ F"-/\\_-7L Detox 20 comes without old adapters for Jest
12
+ | a/ e | \\ and Mocha test runners. You have to rearrange
13
+ ,L,c;,.='/;, your init code before you can continue your
14
+ _,-;;S:;:S;;:' '--._ journey.
15
+ ;. \\;;s:::s;;: .' /\\
16
+ / \\ ;::::;; / / \\ Navigate to the link above and follow the
17
+ / , k ;S';;'S.' j __,l migration guide steps.
18
+ ,---/| / /S /S '. |' ;
19
+ ,Ljjj |/|.' s .' s \\ L | Sincerely yours,
20
+ LL,_ ]( \\ / '. '.|| ; Detox team.
21
+ ||\\ > / ;-.'_.-.___\\.-'(|=="(
22
+ JJ," / |_ [ ] _]| /
23
+ LL\\/ ,' '--'-'-----' \\ (
24
+ || ; | | >
25
+ JJ | |\\ |,/
26
+ LL | || ' |
27
+ || | || . |
28
+ JJ /_ || ;_|
29
+ LL L "==='|i======='_|
30
+ || i----' '-------';
31
+ JJ ';-----.------,-'
32
+ LL L_.__J,'---;'
33
+ || | ,| (
34
+ JJ .'= (| ,_|
35
+ LL / .'L_ \\
36
+ snd || '---' '.___>
37
+ Credit: "Gimli" by Shanaka Dias
38
+
39
+ https://github.com/wix/Detox/blob/master/docs/Guide.Jest.md
40
+
41
+ ========================= THE NEW JOURNEY BEGINS =============================
42
+
43
+ `));
44
+
45
+ throw Object.assign(new Error(
46
+ '\n\nPlease follow the new Jest setup guide:\nhttps://github.com/wix/Detox/blob/master/docs/Guide.Jest.md\n\n'
47
+ ), { stack: '' });