detox 20.0.0-breaking.new-global-lifecycle.0 → 20.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. package/Detox-android/com/wix/detox/{20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.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/{20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.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/{20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom → 20.0.0/detox-20.0.0.pom} +2 -8
  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/build.gradle +13 -8
  30. package/android/detox/build.gradle +14 -10
  31. package/android/detox/proguard-rules-app.pro +6 -0
  32. package/android/detox/proguard-rules.pro +3 -0
  33. package/android/detox/publish-pom.gradle +5 -1
  34. package/android/detox/publishing.gradle +35 -33
  35. package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
  36. package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
  37. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +1 -1
  38. package/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +3 -1
  39. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +1 -3
  40. package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +1 -1
  41. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +22 -0
  42. package/android/detox/src/{main → full}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +13 -1
  43. package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +75 -0
  44. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +16 -23
  45. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
  46. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
  47. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeLoadingMonitor.kt +54 -8
  48. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +19 -13
  49. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +33 -30
  50. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
  51. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
  52. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/RN66Workaround.kt +13 -4
  53. package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +4 -1
  54. package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
  55. package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +2 -1
  56. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +10 -0
  57. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt +1 -1
  58. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
  59. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +15 -3
  60. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +39 -0
  61. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
  62. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
  63. package/android/gradle/wrapper/gradle-wrapper.properties +2 -1
  64. package/android/gradlew +181 -107
  65. package/index.d.ts +198 -57
  66. package/internals.d.ts +220 -51
  67. package/local-cli/build.js +2 -2
  68. package/local-cli/build.test.js +14 -14
  69. package/local-cli/cli.js +8 -6
  70. package/local-cli/init.js +61 -21
  71. package/local-cli/rebuild-framework-cache.js +1 -1
  72. package/local-cli/reset-lock-file.js +16 -0
  73. package/local-cli/templates/jest.js +13 -10
  74. package/local-cli/test.js +14 -8
  75. package/local-cli/test.test.js +148 -61
  76. package/local-cli/testCommand/TestRunnerCommand.js +78 -71
  77. package/local-cli/testCommand/builder.js +0 -1
  78. package/local-cli/testCommand/middlewares.js +4 -13
  79. package/local-cli/testCommand/warnings.js +0 -3
  80. package/local-cli/utils/jestInternals.js +4 -1
  81. package/package.json +22 -15
  82. package/runners/deprecation.js +42 -44
  83. package/runners/jest/globalSetup.js +1 -1
  84. package/runners/jest/globalTeardown.js +1 -1
  85. package/runners/jest/index.d.ts +60 -0
  86. package/runners/jest/index.js +3 -8
  87. package/runners/jest/index.test.js +13 -0
  88. package/runners/jest/reporters/DetoxReporter.js +33 -2
  89. package/runners/jest/testEnvironment/index.js +119 -69
  90. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +94 -51
  91. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
  92. package/runners/jest/testEnvironment/listeners/SpecReporter.js +14 -16
  93. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +2 -6
  94. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  95. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
  96. package/src/DetoxWorker.js +107 -59
  97. package/src/android/core/NativeElement.js +56 -20
  98. package/src/android/core/NativeExpect.js +28 -9
  99. package/src/android/interactions/native.js +25 -18
  100. package/src/artifacts/ArtifactsManager.js +14 -47
  101. package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
  102. package/src/artifacts/log/android/ADBLogcatRecording.js +11 -28
  103. package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
  104. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
  105. package/src/artifacts/templates/artifact/Artifact.js +1 -1
  106. package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
  107. package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
  108. package/src/artifacts/utils/temporaryPath.js +18 -7
  109. package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
  110. package/src/client/AsyncWebSocket.js +8 -17
  111. package/src/client/Client.js +19 -2
  112. package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
  113. package/src/configuration/collectCliConfig.js +1 -12
  114. package/src/configuration/composeAppsConfig.js +5 -1
  115. package/src/configuration/composeDeviceConfig.js +1 -1
  116. package/src/configuration/composeLoggerConfig.js +19 -10
  117. package/src/configuration/composeRunnerConfig.js +62 -9
  118. package/src/configuration/index.js +14 -9
  119. package/src/configuration/loadExternalConfig.js +1 -1
  120. package/src/devices/allocation/DeviceAllocator.js +3 -2
  121. package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
  122. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  123. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
  124. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -2
  125. package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
  126. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
  127. package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +1 -0
  128. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
  129. package/src/devices/common/drivers/android/exec/ADB.js +5 -0
  130. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
  131. package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  132. package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
  133. package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
  134. package/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js +1 -1
  135. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +29 -3
  136. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
  137. package/src/devices/runtime/RuntimeDevice.js +19 -12
  138. package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
  139. package/src/devices/runtime/drivers/android/AndroidDriver.js +10 -2
  140. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
  141. package/src/errors/DetoxConfigErrorComposer.js +18 -3
  142. package/src/ios/expectTwo.js +153 -67
  143. package/src/ipc/IPCClient.js +12 -12
  144. package/src/ipc/IPCServer.js +34 -17
  145. package/src/ipc/{state.js → SessionState.js} +26 -31
  146. package/src/logger/DetoxLogger.js +261 -157
  147. package/src/logger/index.js +5 -0
  148. package/src/logger/utils/BunyanLogger.js +76 -0
  149. package/src/logger/utils/CategoryThreadDispatcher.js +36 -0
  150. package/src/logger/utils/DetoxLogFinalizer.js +140 -0
  151. package/src/logger/utils/MessageStack.js +24 -0
  152. package/src/logger/utils/ThreadDispatcher.js +61 -0
  153. package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +5 -4
  154. package/src/logger/utils/sanitizeBunyanContext.js +30 -0
  155. package/src/{utils → logger/utils}/streamUtils.js +51 -17
  156. package/src/logger/utils/tracerLegacy.js +37 -0
  157. package/src/realms/DetoxContext.js +78 -65
  158. package/src/realms/DetoxInternalsFacade.js +8 -12
  159. package/src/realms/DetoxPrimaryContext.js +106 -73
  160. package/src/realms/DetoxSecondaryContext.js +29 -31
  161. package/src/server/DetoxConnection.js +18 -23
  162. package/src/server/DetoxServer.js +7 -10
  163. package/src/server/DetoxSession.js +6 -6
  164. package/src/server/DetoxSessionManager.js +1 -1
  165. package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
  166. package/src/symbols.js +16 -22
  167. package/src/utils/Timer.js +55 -38
  168. package/src/utils/argparse.js +11 -0
  169. package/src/utils/childProcess/exec.js +1 -1
  170. package/src/utils/childProcess/spawn.js +1 -1
  171. package/src/utils/environment.js +30 -15
  172. package/src/utils/errorUtils.js +24 -3
  173. package/src/utils/invocationTraceDescriptions.js +43 -0
  174. package/src/utils/logger.js +1 -1
  175. package/src/utils/traceInvocationCall.js +21 -0
  176. package/src/utils/traceMethods.js +15 -0
  177. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
  178. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
  179. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
  180. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
  181. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
  182. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
  183. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
  184. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
  185. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar +0 -0
  186. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.md5 +0 -1
  187. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
  188. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
  189. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
  190. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.md5 +0 -1
  191. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
  192. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
  193. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
  194. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
  195. package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -36
  196. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +0 -59
  197. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
  198. package/runners/jest/deprecation.js +0 -25
  199. package/src/configuration/utils/warnings.js +0 -12
  200. package/src/logger/DetoxTraceEventBuilder.js +0 -21
  201. package/src/logger/DetoxTracer.js +0 -133
  202. package/src/logger/TraceThreadDispatcher.js +0 -52
  203. package/src/utils/ChromeTracingExporter.js +0 -53
  204. package/src/utils/trace.js +0 -19
@@ -5,7 +5,7 @@ const { getJestBooleanArgs } = require('../utils/jestInternals');
5
5
  const { simpleUnquote, extractKnownKeys, disengageBooleanArgs } = require('../utils/yargsUtils');
6
6
 
7
7
  const testCommandArgs = require('./builder');
8
- const { DETOX_ARGV_OVERRIDE_NOTICE, DEVICE_LAUNCH_ARGS_DEPRECATION } = require('./warnings');
8
+ const { DETOX_ARGV_OVERRIDE_NOTICE } = require('./warnings');
9
9
 
10
10
  function applyEnvironmentVariableAddendum(argv, yargs) {
11
11
  if (process.env.DETOX_ARGV_OVERRIDE) {
@@ -13,12 +13,13 @@ function applyEnvironmentVariableAddendum(argv, yargs) {
13
13
 
14
14
  const { _: positional, '--': passthrough, ...named } = yargs.parse(process.env.DETOX_ARGV_OVERRIDE);
15
15
 
16
- if (positional) {
16
+ if (!_.isEmpty(positional)) {
17
+ /* istanbul ignore next */
17
18
  argv._ = argv._ || [];
18
19
  argv._.push(...positional.map(simpleUnquote));
19
20
  }
20
21
 
21
- if (passthrough) {
22
+ if (!_.isEmpty(passthrough)) {
22
23
  argv['--'] = argv['--'] || [];
23
24
  argv['--'].push(...passthrough.map(simpleUnquote));
24
25
  }
@@ -29,14 +30,6 @@ function applyEnvironmentVariableAddendum(argv, yargs) {
29
30
  return argv;
30
31
  }
31
32
 
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
33
  /**
41
34
  * @param {Record<string, *>} argv
42
35
  * @returns {{
@@ -64,12 +57,10 @@ function splitArgv(argv) {
64
57
  // noinspection JSUnusedGlobalSymbols
65
58
  module.exports = {
66
59
  applyEnvironmentVariableAddendum,
67
- warnDeviceAppLaunchArgsDeprecation,
68
60
  splitArgv,
69
61
  };
70
62
 
71
63
  module.exports.default = [
72
64
  applyEnvironmentVariableAddendum,
73
- warnDeviceAppLaunchArgsDeprecation,
74
65
  splitArgv,
75
66
  ];
@@ -1,5 +1,3 @@
1
- const { DEVICE_LAUNCH_ARGS_DEPRECATION } = require('../../src/configuration/utils/warnings');
2
-
3
1
  const DETOX_ARGV_OVERRIDE_NOTICE = `
4
2
  _____ _____ ___________
5
3
  / ___|_ _| _ | ___ \\ $DETOX_ARGV_OVERRIDE is detected
@@ -22,5 +20,4 @@ const DETOX_ARGV_OVERRIDE_NOTICE = `
22
20
 
23
21
  module.exports = {
24
22
  DETOX_ARGV_OVERRIDE_NOTICE,
25
- DEVICE_LAUNCH_ARGS_DEPRECATION,
26
23
  };
@@ -4,6 +4,7 @@ const path = require('path');
4
4
 
5
5
  const _ = require('lodash');
6
6
  const resolveFrom = require('resolve-from');
7
+ const semver = require('semver');
7
8
 
8
9
  const { DetoxRuntimeError } = require('../../src/errors');
9
10
 
@@ -50,7 +51,9 @@ function resolveJestCliArgs() {
50
51
 
51
52
  try {
52
53
  const jestCliManifest = resolveJestDependency(jestLocation, 'jest-cli/package.json');
53
- const argsJsFile = path.join(path.dirname(jestCliManifest), 'build/cli/args.js');
54
+ const jestCliVersion = require(jestCliManifest).version;
55
+ const argsJsFilePath = semver.gt(jestCliVersion, '29.1.2') ? 'build/args.js' : 'build/cli/args.js';
56
+ const argsJsFile = path.join(path.dirname(jestCliManifest), argsJsFilePath);
54
57
 
55
58
  return require(argsJsFile);
56
59
  } catch (e) {
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": "20.0.0-breaking.new-global-lifecycle.0",
4
+ "version": "20.0.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -35,8 +35,8 @@
35
35
  "@types/bunyan": "^1.8.8",
36
36
  "@types/child-process-promise": "^2.2.1",
37
37
  "@types/fs-extra": "^9.0.13",
38
- "@types/jest": "^27.0.3",
39
- "@types/node": "^12.20.37",
38
+ "@types/jest": "^28.1.8",
39
+ "@types/node": "^14.18.33",
40
40
  "@types/node-ipc": "^9.2.0",
41
41
  "@types/ws": "^7.4.0",
42
42
  "@typescript-eslint/eslint-plugin": "^5.4.0",
@@ -46,10 +46,10 @@
46
46
  "eslint-plugin-no-only-tests": "^2.6.0",
47
47
  "eslint-plugin-node": "^11.1.0",
48
48
  "eslint-plugin-unicorn": "^39.0.0",
49
- "jest": "^27.5.1",
49
+ "jest": "^28.1.3",
50
50
  "mockdate": "^2.0.1",
51
51
  "prettier": "1.7.0",
52
- "react-native": "0.67.2",
52
+ "react-native": "0.69.7",
53
53
  "react-native-codegen": "^0.0.8",
54
54
  "typescript": "^4.5.2",
55
55
  "wtfnode": "^0.9.1"
@@ -57,13 +57,15 @@
57
57
  "dependencies": {
58
58
  "ajv": "^8.6.3",
59
59
  "bunyan": "^1.8.12",
60
- "bunyan-debug-stream": "^3.0.2",
60
+ "bunyan-debug-stream": "^3.1.0",
61
+ "caf": "^15.0.1",
61
62
  "chalk": "^2.4.2",
62
63
  "child-process-promise": "^2.2.0",
63
64
  "duplexify": "^4.1.2",
64
65
  "find-up": "^4.1.0",
65
66
  "fs-extra": "^4.0.2",
66
67
  "funpermaproxy": "^1.0.1",
68
+ "glob": "^8.0.3",
67
69
  "ini": "^1.3.4",
68
70
  "json-cycle": "^1.3.0",
69
71
  "lodash": "^4.17.5",
@@ -83,7 +85,7 @@
83
85
  "tail": "^2.0.0",
84
86
  "telnet-client": "1.2.8",
85
87
  "tempfile": "^2.0.0",
86
- "trace-event-lib": "^1.1.0",
88
+ "trace-event-lib": "^1.3.1",
87
89
  "which": "^1.3.1",
88
90
  "ws": "^7.0.0",
89
91
  "yargs": "^16.0.3",
@@ -91,7 +93,7 @@
91
93
  "yargs-unparser": "^2.0.0"
92
94
  },
93
95
  "peerDependencies": {
94
- "jest": "28.x.x || ^27.2.5"
96
+ "jest": "29.x.x || 28.x.x || ^27.2.5"
95
97
  },
96
98
  "peerDependenciesMeta": {
97
99
  "jest": {
@@ -99,7 +101,7 @@
99
101
  }
100
102
  },
101
103
  "engines": {
102
- "node": ">=12.10.0"
104
+ "node": ">=14.5.0"
103
105
  },
104
106
  "jest": {
105
107
  "setupFiles": [
@@ -158,7 +160,12 @@
158
160
  "src/utils/pipeCommands.js",
159
161
  "src/utils/pressAnyKey.js",
160
162
  "src/utils/shellUtils.js",
161
- "runners/jest/.*.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"
162
169
  ],
163
170
  "resetMocks": true,
164
171
  "resetModules": true,
@@ -176,12 +183,12 @@
176
183
  ],
177
184
  "coverageThreshold": {
178
185
  "global": {
179
- "statements": 0,
180
- "branches": 0,
181
- "functions": 0,
182
- "lines": 0
186
+ "statements": 100,
187
+ "branches": 100,
188
+ "functions": 100,
189
+ "lines": 100
183
190
  }
184
191
  }
185
192
  },
186
- "gitHead": "e89c826fdbd09989dcb1cc82eb3cc7d821ffbf3e"
193
+ "gitHead": "8c533cd0bbbd514071a31355516292a2cf3c89ce"
187
194
  }
@@ -1,47 +1,45 @@
1
1
  const chalk = require('chalk');
2
2
 
3
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: '' });
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;
@@ -1 +1 @@
1
- module.exports = async () => require('../../internals').globalSetup();
1
+ module.exports = async () => require('../../internals').init({ workerId: null });
@@ -1 +1 @@
1
- module.exports = async () => require('../../internals').globalTeardown();
1
+ module.exports = async () => require('../../internals').cleanup();
@@ -0,0 +1,60 @@
1
+ declare module 'detox/runners/jest' {
2
+ import type NodeEnvironment from 'jest-environment-node';
3
+
4
+ export function globalSetup(): Promise<void>;
5
+ export function globalTeardown(): Promise<void>;
6
+
7
+ export type DetoxCircusListenerConstructorOpts = {
8
+ readonly env: DetoxCircusEnvironment;
9
+ }
10
+
11
+ /**
12
+ * @example
13
+ * class CustomListener implements DetoxCircusListener {
14
+ * constructor(opts: DetoxCircusListenerConstructorOpts) {
15
+ * console.log('Current test path is:', opts.env.testPath);
16
+ * }
17
+ * }
18
+ */
19
+ export interface DetoxCircusListener {
20
+ start_describe_definition?(event: unknown, state: unknown): void;
21
+ finish_describe_definition?(event: unknown, state: unknown): void;
22
+ add_hook?(event: unknown, state: unknown): void;
23
+ add_test?(event: unknown, state: unknown): void;
24
+ error?(event: unknown, state: unknown): void;
25
+
26
+ setup?(event: unknown, state: unknown): void | Promise<void>;
27
+ include_test_location_in_result?(event: unknown, state: unknown): void | Promise<void>;
28
+ hook_start?(event: unknown, state: unknown): void | Promise<void>;
29
+ hook_success?(event: unknown, state: unknown): void | Promise<void>;
30
+ hook_failure?(event: unknown, state: unknown): void | Promise<void>;
31
+ test_fn_start?(event: unknown, state: unknown): void | Promise<void>;
32
+ test_fn_success?(event: unknown, state: unknown): void | Promise<void>;
33
+ test_fn_failure?(event: unknown, state: unknown): void | Promise<void>;
34
+ test_retry?(event: unknown, state: unknown): void | Promise<void>;
35
+ test_start?(event: unknown, state: unknown): void | Promise<void>;
36
+ test_skip?(event: unknown, state: unknown): void | Promise<void>;
37
+ test_todo?(event: unknown, state: unknown): void | Promise<void>;
38
+ test_done?(event: unknown, state: unknown): void | Promise<void>;
39
+ run_describe_start?(event: unknown, state: unknown): void | Promise<void>;
40
+ run_describe_finish?(event: unknown, state: unknown): void | Promise<void>;
41
+ run_start?(event: unknown, state: unknown): void | Promise<void>;
42
+ run_finish?(event: unknown, state: unknown): void | Promise<void>;
43
+ teardown?(event: unknown, state: unknown): void | Promise<void>;
44
+ }
45
+
46
+ export interface DetoxListenerFactory {
47
+ new (opts: DetoxCircusListenerConstructorOpts): DetoxCircusListener;
48
+ }
49
+
50
+ export class DetoxCircusEnvironment extends NodeEnvironment {
51
+ public readonly handleTestEvent: (event: unknown, state: unknown) => void | Promise<void>;
52
+ public readonly testPath: string;
53
+
54
+ protected registerListeners(map: Record<string, DetoxListenerFactory>): void;
55
+ protected setupTimeout: number;
56
+ protected teardownTimeout: number;
57
+ protected initDetox(): Promise<DetoxInternals.Worker>;
58
+ protected cleanupDetox(): Promise<void>;
59
+ }
60
+ }
@@ -1,14 +1,11 @@
1
- module.exports = {
2
- //#region *** Runner Realm ***
1
+ // Lazy require() is used to avoid initializing a bare Detox context when it is not needed.
2
+ // At the moment, this safety measure is not really needed, but it's better to be on the safe side.
3
3
 
4
+ module.exports = {
4
5
  get DetoxCircusEnvironment() {
5
6
  return require('./testEnvironment');
6
7
  },
7
8
 
8
- //#endregion
9
-
10
- //#region *** Worker Realm ***
11
-
12
9
  get globalSetup() {
13
10
  return require('./globalSetup');
14
11
  },
@@ -16,6 +13,4 @@ module.exports = {
16
13
  get globalTeardown() {
17
14
  return require('./globalTeardown');
18
15
  },
19
-
20
- //#endregion
21
16
  };
@@ -0,0 +1,13 @@
1
+ describe('detox/runners/jest', () => {
2
+ it('should lazily require the exported modules', () => {
3
+ const index = require('./index');
4
+
5
+ jest.mock('./testEnvironment', () => 0);
6
+ jest.mock('./globalSetup', () => 1);
7
+ jest.mock('./globalTeardown', () => 2);
8
+
9
+ expect(index.DetoxCircusEnvironment).toBe(0);
10
+ expect(index.globalSetup).toBe(1);
11
+ expect(index.globalTeardown).toBe(2);
12
+ });
13
+ });
@@ -1,5 +1,36 @@
1
- const { VerboseReporter: JestVerboseReporter } = require('@jest/reporters'); // eslint-disable-line node/no-extraneous-require
1
+ const resolveFrom = require('resolve-from');
2
+ /** @type {typeof import('@jest/reporters').VerboseReporter} */
3
+ const JestVerboseReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).VerboseReporter;
2
4
 
3
- class DetoxReporter extends JestVerboseReporter {}
5
+ const { config, reportTestResults } = require('../../../internals');
6
+
7
+ class DetoxReporter extends JestVerboseReporter {
8
+ /**
9
+ * @param {import('@jest/test-result').AggregatedResult} results
10
+ */
11
+ // @ts-ignore
12
+ async onRunComplete(_contexts, results) {
13
+ // @ts-ignore
14
+ await super.onRunComplete(_contexts, results);
15
+
16
+ await reportTestResults(results.testResults.map(r => ({
17
+ success: !r.failureMessage,
18
+ testFilePath: r.testFilePath,
19
+ testExecError: r.testExecError,
20
+ isPermanentFailure: this._isPermanentFailure(r),
21
+ })));
22
+ }
23
+
24
+ /**
25
+ * @param {import('@jest/test-result').TestResult} testResult
26
+ */
27
+ _isPermanentFailure(testResult) {
28
+ if (config.testRunner.jest.retryAfterCircusRetries) {
29
+ return false;
30
+ }
31
+
32
+ return testResult.testResults.some(r => r.status === 'failed' && r.invocations > 1);
33
+ }
34
+ }
4
35
 
5
36
  module.exports = DetoxReporter;