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,27 @@
1
+ const _ = require('lodash');
2
+
3
+ const { device } = require('../../../..');
4
+
5
+ const PLATFORM_REGEXP = /^:([^:]+):/;
6
+
7
+ class DetoxPlatformFilterListener {
8
+ setup() {
9
+ this._platform = device.getPlatform();
10
+ }
11
+
12
+ start_describe_definition(event, state) {
13
+ const match = event.blockName.match(PLATFORM_REGEXP);
14
+ if (match && match[1] !== this._platform) {
15
+ state.currentDescribeBlock.mode = 'skip';
16
+ }
17
+ }
18
+
19
+ add_test(event, state) {
20
+ const match = event.testName.match(PLATFORM_REGEXP);
21
+ if (match && match[1] !== this._platform) {
22
+ _.last(state.currentDescribeBlock.children).mode = 'skip';
23
+ }
24
+ }
25
+ }
26
+
27
+ module.exports = DetoxPlatformFilterListener;
@@ -1,8 +1,8 @@
1
1
  const chalk = require('chalk').default;
2
+ const noop = require('lodash/noop');
2
3
 
3
- const log = require('../../src/utils/logger').child();
4
-
5
- const { traceln } = require('./utils/stdout');
4
+ const { config, log, session } = require('../../../../internals');
5
+ const { traceln } = require('../utils/stdout');
6
6
 
7
7
  const RESULT_SKIPPED = chalk.yellow('SKIPPED');
8
8
  const RESULT_FAILED = chalk.red('FAIL');
@@ -16,12 +16,64 @@ class SpecReporter {
16
16
  this._suitesDesc = '';
17
17
  }
18
18
 
19
- onSuiteStart({ description }) {
19
+ setup() {
20
+ const jestSection = config.testRunner.jest;
21
+ const reportSpecs = jestSection && jestSection.reportSpecs;
22
+ const enabled = reportSpecs !== undefined ? reportSpecs : session.workersCount === 1;
23
+
24
+ if (!enabled) {
25
+ this.run_describe_start = noop;
26
+ this.run_describe_finish = noop;
27
+ this.test_start = noop;
28
+ this.test_done = noop;
29
+ this.test_skip = noop;
30
+ }
31
+ }
32
+
33
+ run_describe_start(event) {
34
+ if (event.describeBlock.parent !== undefined) {
35
+ this._onSuiteStart({
36
+ description: event.describeBlock.name,
37
+ });
38
+ }
39
+ }
40
+
41
+ run_describe_finish(event) {
42
+ if (event.describeBlock.parent !== undefined) {
43
+ this._onSuiteEnd();
44
+ }
45
+ }
46
+
47
+ test_start(event) {
48
+ const { test } = event;
49
+ this._onTestStart({
50
+ description: test.name,
51
+ invocations: test.invocations,
52
+ });
53
+ }
54
+
55
+ test_done(event) {
56
+ const { test } = event;
57
+ const testInfo = {
58
+ description: test.name,
59
+ invocations: test.invocations,
60
+ };
61
+ this._onTestEnd(testInfo, test.errors.length ? 'failed' : 'success');
62
+ }
63
+
64
+ test_skip(event) {
65
+ const testInfo = {
66
+ description: event.test.name,
67
+ };
68
+ this._onTestEnd(testInfo, 'skipped');
69
+ }
70
+
71
+ _onSuiteStart({ description }) {
20
72
  this._suites.push({ description });
21
73
  this._regenerateSuitesDesc();
22
74
  }
23
75
 
24
- onSuiteEnd() {
76
+ _onSuiteEnd() {
25
77
  this._suites.pop();
26
78
  this._regenerateSuitesDesc();
27
79
 
@@ -30,11 +82,11 @@ class SpecReporter {
30
82
  }
31
83
  }
32
84
 
33
- onTestStart({ description, invocations = 1 }) {
85
+ _onTestStart({ description, invocations = 1 }) {
34
86
  this._traceTest({ description, invocations });
35
87
  }
36
88
 
37
- onTestEnd({ description, invocations = 1 }, result) {
89
+ _onTestEnd({ description, invocations = 1 }, result) {
38
90
  let status;
39
91
  switch (result) {
40
92
  case 'skipped': status = RESULT_SKIPPED; break;
@@ -56,7 +108,7 @@ class SpecReporter {
56
108
  .concat(suite.description)
57
109
  .concat((index === total - 1) ? ': ' : '');
58
110
  });
59
- this._suitesDesc = chalk.bold.white(this._suitesDesc);
111
+ this._suitesDesc = chalk.bold(this._suitesDesc);
60
112
  }
61
113
 
62
114
  _traceTest({ description, invocations }, _status = undefined) {
@@ -64,7 +116,7 @@ class SpecReporter {
64
116
  const retriesDescription = (invocations > 1) ? chalk.gray(` [Retry #${invocations - 1}]`) : '';
65
117
  const status = chalk.gray(_status ? ` [${_status}]` : '');
66
118
  const desc = this._suitesDesc + testDescription + retriesDescription + status;
67
- log.info({ event: 'SPEC_STATE_CHANGE' }, desc);
119
+ log.info({ cat: 'lifecycle' }, desc);
68
120
  }
69
121
  }
70
122
 
@@ -0,0 +1,30 @@
1
+ const path = require('path');
2
+
3
+ const chalk = require('chalk').default;
4
+ const _ = require('lodash');
5
+
6
+ const { device } = require('../../../..');
7
+ const { config, log } = require('../../../../internals');
8
+
9
+ class WorkerAssignReporter {
10
+ constructor({ env }) {
11
+ this._testName = path.basename(env.testPath);
12
+ }
13
+
14
+ run_start() {
15
+ if (config.testRunner.jest.reportWorkerAssign) {
16
+ log.info({ cat: 'lifecycle' }, `${chalk.bold(this._testName)} is assigned to ${this._formatDeviceName()}`);
17
+ }
18
+ }
19
+
20
+ _formatDeviceName() {
21
+ const deviceName = _.attempt(() => device.name);
22
+ const formattedDeviceName = _.isError(deviceName)
23
+ ? chalk.redBright('undefined')
24
+ : chalk.blueBright(deviceName);
25
+
26
+ return formattedDeviceName;
27
+ }
28
+ }
29
+
30
+ module.exports = WorkerAssignReporter;
@@ -0,0 +1,13 @@
1
+ const DetoxCoreListener = require('./DetoxCoreListener');
2
+ const DetoxInitErrorListener = require('./DetoxInitErrorListener');
3
+ const DetoxPlatformFilterListener = require('./DetoxPlatformFilterListener');
4
+ const SpecReporter = require('./SpecReporter');
5
+ const WorkerAssignReporter = require('./WorkerAssignReporter');
6
+
7
+ module.exports = {
8
+ DetoxCoreListener,
9
+ DetoxInitErrorListener,
10
+ DetoxPlatformFilterListener,
11
+ SpecReporter,
12
+ WorkerAssignReporter,
13
+ };
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
- const { DetoxRuntimeError } = require('../../../src/errors/DetoxRuntimeError');
3
- const { filterErrorStack } = require('../../../src/utils/errorUtils');
2
+ const { DetoxRuntimeError } = require('../../../../src/errors/DetoxRuntimeError');
3
+ const { filterErrorStack } = require('../../../../src/utils/errorUtils');
4
4
 
5
5
  function findUserConstructor() {
6
6
  let wasInBaseClass = false;
@@ -0,0 +1,70 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const resolveFrom = require('resolve-from');
5
+ const semver = require('semver');
6
+
7
+ const { log } = require('../../../../internals');
8
+ const detoxPackageJson = require('../../../../package.json');
9
+ const { DetoxRuntimeError } = require('../../../../src/errors');
10
+
11
+ function assertJestCircus27(maybeProjectConfig) {
12
+ const projectConfig = maybeProjectConfig.projectConfig || maybeProjectConfig;
13
+
14
+ if (!/jest-circus/.test(projectConfig.testRunner)) {
15
+ throw new DetoxRuntimeError({
16
+ message: 'Cannot continue without Jest Circus test runner underneath, exiting.',
17
+ hint: 'Make sure that in your Jest config you have no "testRunner" property or it is explicitly set to "jest-circus/runner".',
18
+ debugInfo: `The test runner powering your configuration is:\n${projectConfig.testRunner}`,
19
+ });
20
+ }
21
+
22
+ const circusPackageJson = path.join(path.dirname(projectConfig.testRunner), 'package.json');
23
+ if (!fs.existsSync(circusPackageJson)) {
24
+ throw new DetoxRuntimeError({
25
+ message: 'Check that you have an installed copy of "jest-circus" npm package, exiting.',
26
+ debugInfo: `Its package.json file is missing: ${circusPackageJson}`,
27
+ });
28
+ }
29
+
30
+ const jestManifestPath = resolveFrom(process.cwd(), 'jest/package.json');
31
+ const jestManifest = require(jestManifestPath);
32
+ assertSupportedVersion(jestManifest.version);
33
+
34
+ const circusVersion = require(circusPackageJson).version;
35
+ if (!circusVersion) {
36
+ throw new DetoxRuntimeError({
37
+ message: 'Check that you have an valid copy of "jest-circus" npm package, exiting.',
38
+ debugInfo: `Its package.json file has no "version" property. See:\n` + circusPackageJson,
39
+ });
40
+ }
41
+
42
+ if (jestManifest.version !== circusVersion) {
43
+ log.warn([
44
+ `jest-circus@${circusVersion} does not match jest@${jestManifest.version}.\n`,
45
+ `- jest@${jestManifest.version} resolved path:\n\t${jestManifestPath}`,
46
+ `- jest-circus@${circusVersion} resolved path:\n\t${circusPackageJson}`,
47
+ `\nPlease make sure that your versions match to avoid unexpected behavior!`,
48
+ ].join('\n'));
49
+ }
50
+
51
+ return maybeProjectConfig;
52
+ }
53
+
54
+ function assertSupportedVersion(actualVersion) {
55
+ const supportedRange = detoxPackageJson.peerDependencies.jest;
56
+ const minSupportedVersion = semver.minVersion(supportedRange);
57
+ const action = semver.lt(actualVersion, minSupportedVersion) ? 'upgrade' : 'downgrade';
58
+
59
+ if (!semver.satisfies(actualVersion, supportedRange, { includePrerelease: true })) {
60
+ throw new DetoxRuntimeError({
61
+ message: `Detected an unsupported jest@${actualVersion} version.`,
62
+ hint: `Please ${action} your Jest test runner to the supported range: ${supportedRange}.`
63
+ });
64
+ }
65
+ }
66
+
67
+ module.exports = {
68
+ assertJestCircus27,
69
+ assertSupportedVersion,
70
+ };
@@ -0,0 +1,22 @@
1
+ const { assertSupportedVersion } = require('./assertJestCircus27');
2
+
3
+ describe('assertSupportedVersion', () => {
4
+ test.each([
5
+ ['27.2.5'],
6
+ ['27.2.6-prerelease.0'],
7
+ ['27.3.0'],
8
+ ['28.0.0-alpha.1'],
9
+ ['28.0.0'],
10
+ ['28.1.0'],
11
+ ['29.0.0-next.0'],
12
+ ])('should pass for %j', (version) => {
13
+ expect(() => assertSupportedVersion(version)).not.toThrow();
14
+ });
15
+
16
+ test.each([
17
+ ['26.0.0'],
18
+ ['27.2.4'],
19
+ ])('should throw an error for %j', (version) => {
20
+ expect(() => assertSupportedVersion(version)).toThrowError(/unsupported jest.*version/);
21
+ });
22
+ });
@@ -0,0 +1,6 @@
1
+ const path = require('path');
2
+
3
+ module.exports = require('../../migration')(
4
+ __filename,
5
+ path.join(__dirname, '../../jest/testEnvironment/index.js')
6
+ );
@@ -1,10 +1 @@
1
- const SpecReporterCircus = require('../jest/SpecReporterCircus');
2
- const WorkerAssignReporterCircus = require('../jest/WorkerAssignReporterCircus');
3
-
4
- const DetoxCircusEnvironment = require('./environment');
5
-
6
- module.exports = {
7
- DetoxCircusEnvironment,
8
- SpecReporter: SpecReporterCircus,
9
- WorkerAssignReporter: WorkerAssignReporterCircus,
10
- };
1
+ module.exports = require('../migration')(__filename);
@@ -0,0 +1 @@
1
+ module.exports = require('../migration')(__filename);
@@ -0,0 +1,37 @@
1
+ const path = require('path');
2
+
3
+ const chalk = require('chalk');
4
+ const _ = require('lodash');
5
+
6
+ const SEARCH_VALUE = ['', 'detox', 'runners', 'jest-circus', ''].join(path.sep);
7
+ const REPLACE_VALUE = ['', 'detox', 'runners', 'jest', ''].join(path.sep);
8
+
9
+ function jsify(pathToFile) {
10
+ return 'detox/' + path
11
+ .relative(
12
+ path.join(__dirname, '..'),
13
+ pathToFile
14
+ )
15
+ .replace(/\\/g, '/')
16
+ .replace(/(?:\/index)?\.js$/, '');
17
+ }
18
+
19
+ const redirectWithWarning = _.memoize((
20
+ oldPath,
21
+ newPath = oldPath.replace(SEARCH_VALUE, REPLACE_VALUE)
22
+ ) => {
23
+ redirectWithWarning._log([
24
+ '[DEPRECATION] Detox detected an attempt to require a module from an outdated location, please change in your project:',
25
+ `- ${jsify(oldPath)}`,
26
+ `+ ${jsify(newPath)}`,
27
+ '',
28
+ ].join('\n'));
29
+
30
+ return require(newPath);
31
+ });
32
+
33
+ // @ts-ignore
34
+ // istanbul ignore next
35
+ redirectWithWarning._log = msg => process.stderr.write(chalk.yellow(msg) + '\n');
36
+
37
+ module.exports = redirectWithWarning;
@@ -1,35 +1,3 @@
1
- class DetoxMochaAdapter {
2
- constructor(detox) {
3
- this.detox = detox;
4
- }
5
-
6
- async beforeEach(context) {
7
- await this.detox.beforeEach({
8
- title: context.currentTest.title,
9
- fullName: context.currentTest.fullTitle(),
10
- status: this._mapStatus(context, false),
11
- });
12
- }
13
-
14
- async afterEach(context) {
15
- await this.detox.afterEach({
16
- title: context.currentTest.title,
17
- fullName: context.currentTest.fullTitle(),
18
- status: this._mapStatus(context, true),
19
- timedOut: context.currentTest.timedOut,
20
- });
21
- }
22
-
23
- _mapStatus(context, isAfterTest) {
24
- switch (context.currentTest.state) {
25
- case 'passed':
26
- return 'passed';
27
- case 'failed':
28
- return 'failed';
29
- default:
30
- return isAfterTest ? 'failed' : 'running';
31
- }
32
- }
33
- }
34
-
35
- module.exports = DetoxMochaAdapter;
1
+ /** @deprecated */
2
+ /** @type {never} */
3
+ module.exports = require('../deprecation');
@@ -1,9 +1,6 @@
1
- interface DetoxMochaAdapter {
2
- detox: Detox.DetoxExportWrapper;
3
- beforeEach: (context: any) => Promise<void>;
4
- afterEach: (context: any) => Promise<void>;
5
- }
6
-
7
- declare const adapter: DetoxMochaAdapter;
1
+ /**
2
+ * @deprecated Mocha integration is no longer supported since Detox v20.0.0
3
+ */
4
+ declare const adapter: never;
8
5
 
9
6
  export = adapter;
@@ -1,5 +1,3 @@
1
- const detox = require('../../src/index');
2
-
3
- const DetoxMochaAdapter = require('./DetoxMochaAdapter');
4
-
5
- module.exports = new DetoxMochaAdapter(detox);
1
+ /** @deprecated */
2
+ /** @type {never} */
3
+ module.exports = require('../deprecation');