detox 21.0.0-rc.1 → 21.0.0-rc.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.js +1 -40
  3. package/Detox-android/com/wix/detox/{21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar → 21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar} +0 -0
  4. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.md5 +1 -0
  5. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha1 +1 -0
  6. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha256 +1 -0
  7. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha512 +1 -0
  8. package/Detox-android/com/wix/detox/{21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar → 21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar} +0 -0
  9. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.md5 +1 -0
  10. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha1 +1 -0
  11. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha256 +1 -0
  12. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha512 +1 -0
  13. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar +0 -0
  14. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.md5 +1 -0
  15. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha1 +1 -0
  16. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha256 +1 -0
  17. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha512 +1 -0
  18. package/Detox-android/com/wix/detox/{21.0.0-rc.1/detox-21.0.0-rc.1.pom → 21.0.0-rc.10/detox-21.0.0-rc.10.pom} +1 -7
  19. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.md5 +1 -0
  20. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha1 +1 -0
  21. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha256 +1 -0
  22. package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha512 +1 -0
  23. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  26. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  27. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  28. package/Detox-ios-framework.tbz +0 -0
  29. package/Detox-ios-src.tbz +0 -0
  30. package/Detox-ios-xcuitest.tbz +0 -0
  31. package/android/build.gradle +20 -10
  32. package/android/detox/build.gradle +24 -12
  33. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAssertion.java +44 -25
  34. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +12 -12
  35. package/android/detox/src/full/java/com/wix/detox/espresso/EspressoDetox.java +6 -7
  36. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +2 -2
  37. package/android/detox/src/full/java/com/wix/detox/espresso/action/GetAttributesAction.kt +34 -35
  38. package/android/detox/src/full/java/com/wix/detox/espresso/common/MaterialSliderHelper.kt +21 -0
  39. package/android/detox/src/full/java/com/wix/detox/espresso/common/{SliderHelper.kt → ReactSliderHelper.kt} +7 -6
  40. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/RegexMatcher.kt +56 -0
  41. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +18 -6
  42. package/android/detox/src/full/java/com/wix/detox/espresso/performer/MultipleViewsActionPerformer.kt +43 -0
  43. package/android/detox/src/full/java/com/wix/detox/espresso/performer/SingleViewActionPerformer.kt +19 -0
  44. package/android/detox/src/full/java/com/wix/detox/espresso/performer/ViewActionPerformer.kt +24 -0
  45. package/android/detox/src/full/java/com/wix/detox/espresso/web/WebElement.java +4 -4
  46. package/android/detox/src/full/java/com/wix/invoke/types/Invocation.java +7 -6
  47. package/android/detox/src/main/java/com/wix/detox/espresso/MultipleViewsAction.kt +4 -0
  48. package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +0 -1
  49. package/android/detox/src/main/java/com/wix/detox/espresso/ViewActionWithResult.kt +2 -1
  50. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/MotionEvents.kt +60 -4
  51. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +6 -5
  52. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/MaterialSliderHelperTest.kt +33 -0
  53. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/{SliderHelperTest.kt → ReactSliderHelperTest.kt} +3 -3
  54. package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/RegexMatcherTest.kt +52 -0
  55. package/android/detox/src/testFull/java/com/wix/detox/espresso/performer/ViewActionPerformerSpec.kt +37 -0
  56. package/android/detox/src/testFull/java/com/wix/invoke/JsonParserTest.java +23 -7
  57. package/android/detox/src/testFull/resources/targetInvocationEspressoWebDetoxScript.json +47 -0
  58. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  59. package/android/rninfo.gradle +25 -0
  60. package/android/settings.gradle +2 -1
  61. package/detox.d.ts +1840 -0
  62. package/globals.d.ts +23 -0
  63. package/index.d.ts +2 -1789
  64. package/internals.d.ts +11 -1
  65. package/jest.config.js +108 -0
  66. package/local-cli/reset-lock-file.js +5 -9
  67. package/local-cli/startCommand/AppStartCommand.js +4 -1
  68. package/local-cli/testCommand/TestRunnerCommand.js +26 -3
  69. package/local-cli/utils/interruptListeners.js +15 -0
  70. package/package.json +15 -108
  71. package/runners/jest/reporter.js +21 -1
  72. package/runners/jest/reporters/DetoxIPCReporter.js +34 -0
  73. package/runners/jest/reporters/DetoxReporterDispatcher.js +144 -0
  74. package/runners/jest/reporters/DetoxSummaryReporter.js +16 -0
  75. package/runners/jest/reporters/DetoxVerboseReporter.js +16 -0
  76. package/runners/jest/reporters/index.js +6 -0
  77. package/runners/jest/testEnvironment/index.js +11 -0
  78. package/src/DetoxWorker.js +5 -11
  79. package/src/android/core/NativeElement.js +26 -29
  80. package/src/android/core/WebElement.js +24 -6
  81. package/src/android/espressoapi/DetoxAssertion.js +16 -14
  82. package/src/android/espressoapi/DetoxMatcher.js +24 -8
  83. package/src/android/espressoapi/EspressoDetox.js +9 -2
  84. package/src/android/espressoapi/web/WebElement.js +1 -4
  85. package/src/android/interactions/native.js +2 -3
  86. package/src/android/matchers/index.js +4 -0
  87. package/src/android/matchers/native.js +9 -4
  88. package/src/android/matchers/web.js +26 -1
  89. package/src/artifacts/providers/index.js +3 -3
  90. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +0 -17
  91. package/src/configuration/composeLoggerConfig.js +1 -0
  92. package/src/configuration/composeRunnerConfig.js +3 -1
  93. package/src/devices/allocation/DeviceAllocator.js +66 -20
  94. package/src/devices/allocation/DeviceList.js +44 -0
  95. package/src/devices/allocation/DeviceRegistry.js +189 -0
  96. package/src/devices/allocation/drivers/AllocationDriverBase.d.ts +15 -0
  97. package/src/devices/{common/drivers/android/tools → allocation/drivers/android}/FreeDeviceFinder.js +11 -10
  98. package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +22 -17
  99. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +97 -38
  100. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +32 -45
  101. package/src/devices/allocation/drivers/android/emulator/FreeEmulatorFinder.js +1 -1
  102. package/src/devices/allocation/drivers/android/emulator/FreePortFinder.js +37 -0
  103. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -3
  104. package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +104 -32
  105. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceLauncher.js +40 -31
  106. package/src/devices/allocation/drivers/android/genycloud/GenyRegistry.js +121 -0
  107. package/src/devices/allocation/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +24 -0
  108. package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  109. package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyInstance.js +83 -0
  110. package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyRecipe.js +25 -0
  111. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +95 -54
  112. package/src/devices/allocation/drivers/ios/SimulatorQuery.js +24 -0
  113. package/src/devices/allocation/factories/android.js +29 -35
  114. package/src/devices/allocation/factories/ios.js +6 -7
  115. package/src/devices/common/drivers/DeviceCookie.d.ts +12 -0
  116. package/src/devices/common/drivers/android/cookies.d.ts +11 -0
  117. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +17 -5
  118. package/src/devices/common/drivers/android/exec/ADB.js +1 -0
  119. package/src/devices/common/drivers/android/tools/instrumentationArgs.js +7 -1
  120. package/src/devices/common/drivers/ios/cookies.d.ts +9 -0
  121. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +3 -1
  122. package/src/devices/cookies/index.js +0 -6
  123. package/src/devices/runtime/drivers/android/genycloud/GenyCloudDriver.js +7 -6
  124. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +5 -4
  125. package/src/devices/runtime/drivers/ios/XCUITestUtils.js +21 -11
  126. package/src/devices/runtime/factories/android.js +3 -11
  127. package/src/devices/runtime/factories/ios.js +3 -4
  128. package/src/{servicelocator → devices/servicelocator}/android/emulatorServiceLocator.js +1 -1
  129. package/src/devices/servicelocator/android/genycloudServiceLocator.js +17 -0
  130. package/src/devices/servicelocator/android/index.js +23 -0
  131. package/src/{validation → devices/validation}/EnvironmentValidatorBase.js +1 -0
  132. package/src/{validation → devices/validation}/android/GenycloudEnvValidator.js +2 -2
  133. package/src/{validation → devices/validation}/factories/index.js +1 -1
  134. package/src/{validation → devices/validation}/ios/IosSimulatorEnvValidator.js +2 -2
  135. package/src/environmentFactory.js +1 -11
  136. package/src/invoke.js +0 -2
  137. package/src/ios/expectTwo.js +28 -11
  138. package/src/ios/web.js +302 -0
  139. package/src/ipc/IPCClient.js +22 -1
  140. package/src/ipc/IPCServer.js +42 -1
  141. package/src/ipc/SessionState.js +1 -0
  142. package/src/logger/DetoxLogger.js +2 -2
  143. package/src/realms/DetoxContext.js +8 -0
  144. package/src/realms/DetoxInternalsFacade.js +1 -0
  145. package/src/realms/DetoxPrimaryContext.js +49 -44
  146. package/src/realms/DetoxSecondaryContext.js +27 -0
  147. package/src/realms/symbols.js +6 -0
  148. package/src/utils/PIDService.js +27 -0
  149. package/src/utils/assertIsFunction.js +35 -0
  150. package/src/utils/environment.js +8 -15
  151. package/src/utils/errorUtils.js +3 -3
  152. package/src/utils/invocationTraceDescriptions.js +16 -0
  153. package/src/utils/isArrowFunction.js +24 -0
  154. package/src/utils/isRegExp.js +7 -0
  155. package/tsconfig.json +8 -3
  156. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.md5 +0 -1
  157. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.sha1 +0 -1
  158. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.sha256 +0 -1
  159. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.sha512 +0 -1
  160. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.md5 +0 -1
  161. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.sha1 +0 -1
  162. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.sha256 +0 -1
  163. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.sha512 +0 -1
  164. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar +0 -0
  165. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.md5 +0 -1
  166. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.sha1 +0 -1
  167. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.sha256 +0 -1
  168. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.sha512 +0 -1
  169. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.md5 +0 -1
  170. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.sha1 +0 -1
  171. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.sha256 +0 -1
  172. package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.sha512 +0 -1
  173. package/runners/jest/reporters/DetoxReporter.js +0 -36
  174. package/src/devices/DeviceRegistry.js +0 -176
  175. package/src/devices/allocation/drivers/AllocationDriverBase.js +0 -30
  176. package/src/devices/allocation/drivers/android/attached/AttachedAndroidLauncher.js +0 -13
  177. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +0 -72
  178. package/src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory.js +0 -16
  179. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +0 -65
  180. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +0 -21
  181. package/src/devices/common/drivers/DeviceAllocationHelper.js +0 -20
  182. package/src/devices/common/drivers/DeviceLauncher.js +0 -19
  183. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +0 -25
  184. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLookupService.js +0 -38
  185. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +0 -14
  186. package/src/devices/common/drivers/android/genycloud/services/dto/GenyInstance.js +0 -66
  187. package/src/devices/common/drivers/android/genycloud/services/dto/GenyRecipe.js +0 -13
  188. package/src/devices/cookies/AndroidDeviceCookie.js +0 -13
  189. package/src/devices/cookies/AndroidEmulatorCookie.js +0 -6
  190. package/src/devices/cookies/AttachedAndroidDeviceCookie.js +0 -12
  191. package/src/devices/cookies/DeviceCookie.js +0 -4
  192. package/src/devices/cookies/GenycloudEmulatorCookie.js +0 -20
  193. package/src/devices/cookies/IosCookie.js +0 -6
  194. package/src/devices/cookies/IosSimulatorCookie.js +0 -10
  195. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +0 -71
  196. package/src/devices/lifecycle/factories/GenyGlobalLifecycleHandlerFactory.js +0 -18
  197. package/src/invoke/EarlGrey.js +0 -8
  198. package/src/servicelocator/android/genycloudServiceLocator.js +0 -21
  199. package/src/servicelocator/android/index.js +0 -25
  200. package/src/servicelocator/ios.js +0 -7
  201. /package/src/devices/{common → allocation}/drivers/android/genycloud/exec/GenyCloudExec.js +0 -0
  202. /package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyAuthService.js +0 -0
package/index.d.ts CHANGED
@@ -1,1792 +1,5 @@
1
- // TypeScript definitions for Detox
2
- // Original authors (from DefinitelyTyped):
3
- // * Jane Smith <jsmith@example.com>
4
- // * Tareq El-Masri <https://github.com/TareqElMasri>
5
- // * Steve Chun <https://github.com/stevechun>
6
- // * Hammad Jutt <https://github.com/hammadj>
7
- // * pera <https://github.com/santiagofm>
8
- // * Max Komarychev <https://github.com/maxkomarychev>
9
- // * Dor Ben Baruch <https://github.com/Dor256>
10
-
11
- import { BunyanDebugStreamOptions } from 'bunyan-debug-stream';
12
-
13
- declare global {
14
- const detox: Detox.DetoxExportWrapper;
15
- const device: Detox.DetoxExportWrapper['device'];
16
- const element: Detox.DetoxExportWrapper['element'];
17
- const waitFor: Detox.DetoxExportWrapper['waitFor'];
18
- const expect: Detox.DetoxExportWrapper['expect'];
19
- const by: Detox.DetoxExportWrapper['by'];
20
- const web: Detox.DetoxExportWrapper['web'];
21
-
22
- namespace NodeJS {
23
- interface Global {
24
- detox: Detox.DetoxExportWrapper;
25
- device: Detox.DetoxExportWrapper['device'];
26
- element: Detox.DetoxExportWrapper['element'];
27
- waitFor: Detox.DetoxExportWrapper['waitFor'];
28
- expect: Detox.DetoxExportWrapper['expect'];
29
- by: Detox.DetoxExportWrapper['by'];
30
- web: Detox.DetoxExportWrapper['web'];
31
- }
32
- }
33
-
34
- namespace Detox {
35
- //#region DetoxConfig
36
-
37
- interface DetoxConfig extends DetoxConfigurationCommon {
38
- /**
39
- * @example extends: './relative/detox.config'
40
- * @example extends: '@my-org/detox-preset'
41
- */
42
- extends?: string;
43
-
44
- apps?: Record<string, DetoxAppConfig>;
45
- devices?: Record<string, DetoxDeviceConfig>;
46
- selectedConfiguration?: string;
47
- configurations: Record<string, DetoxConfiguration>;
48
- }
49
-
50
- type DetoxConfigurationCommon = {
51
- artifacts?: false | DetoxArtifactsConfig;
52
- behavior?: DetoxBehaviorConfig;
53
- logger?: DetoxLoggerConfig;
54
- session?: DetoxSessionConfig;
55
- testRunner?: DetoxTestRunnerConfig;
56
- };
57
-
58
- interface DetoxArtifactsConfig {
59
- rootDir?: string;
60
- pathBuilder?: string;
61
- plugins?: {
62
- log?: 'none' | 'failing' | 'all' | DetoxLogArtifactsPluginConfig;
63
- screenshot?: 'none' | 'manual' | 'failing' | 'all' | DetoxScreenshotArtifactsPluginConfig;
64
- video?: 'none' | 'failing' | 'all' | DetoxVideoArtifactsPluginConfig;
65
- instruments?: 'none' | 'all' | DetoxInstrumentsArtifactsPluginConfig;
66
- uiHierarchy?: 'disabled' | 'enabled' | DetoxUIHierarchyArtifactsPluginConfig;
67
-
68
- [pluginId: string]: unknown;
69
- };
70
- }
71
-
72
- interface DetoxBehaviorConfig {
73
- init?: {
74
- /**
75
- * By default, Detox exports `device`, `expect`, `element`, `by` and `waitFor`
76
- * as global variables. If you want to control their initialization manually,
77
- * set this property to `false`.
78
- *
79
- * This is useful when during E2E tests you also need to run regular expectations
80
- * in Node.js. Jest's `expect` for instance, will not be overridden by Detox when
81
- * this option is used.
82
- */
83
- exposeGlobals?: boolean;
84
- /**
85
- * By default, Detox will uninstall and install the app upon initialization.
86
- * If you wish to reuse the existing app for a faster run, set the property to
87
- * `false`.
88
- */
89
- reinstallApp?: boolean;
90
- /**
91
- * When false, `detox test` command always deletes the shared lock file on start,
92
- * assuming it had been left from the previous, already finished test session.
93
- * The lock file contains information about busy and free devices and ensures
94
- * no device can be used simultaneously by multiple test workers.
95
- *
96
- * Setting it to **true** might be useful when if you need to run multiple
97
- * `detox test` commands in parallel, e.g. test a few configurations at once.
98
- *
99
- * @default false
100
- */
101
- keepLockFile?: boolean;
102
- };
103
- launchApp?: 'auto' | 'manual';
104
- cleanup?: {
105
- shutdownDevice?: boolean;
106
- };
107
- }
108
-
109
- type _DetoxLoggerOptions = Omit<BunyanDebugStreamOptions, 'out'>;
110
-
111
- interface DetoxLoggerConfig {
112
- /**
113
- * Log level filters the messages printed to your terminal,
114
- * and it does not affect the logs written to the artifacts.
115
- *
116
- * Use `info` by default.
117
- * Use `error` or warn when you want to make the output as silent as possible.
118
- * Use `debug` to control what generally is happening under the hood.
119
- * Use `trace` when troubleshooting specific issues.
120
- *
121
- * @default 'info'
122
- */
123
- level?: DetoxLogLevel;
124
- /**
125
- * When enabled, hijacks all the console methods (console.log, console.warn, etc)
126
- * so that the messages printed via them are formatted and saved as Detox logs.
127
- *
128
- * @default true
129
- */
130
- overrideConsole?: boolean;
131
- /**
132
- * Since Detox is using
133
- * {@link https://www.npmjs.com/package/bunyan-debug-stream bunyan-debug-stream}
134
- * for printing logs, all its options are exposed for sake of simplicity
135
- * of customization.
136
- *
137
- * The only exception is {@link BunyanDebugStreamOptions#out} option,
138
- * which is always set to `process.stdout`.
139
- *
140
- * You can also pass a callback function to override the logger config
141
- * programmatically, e.g. depending on the selected log level.
142
- *
143
- * @see {@link BunyanDebugStreamOptions}
144
- */
145
- options?: _DetoxLoggerOptions | ((config: Partial<DetoxLoggerConfig>) => _DetoxLoggerOptions);
146
- }
147
-
148
- interface DetoxSessionConfig {
149
- autoStart?: boolean;
150
- debugSynchronization?: number;
151
- server?: string;
152
- sessionId?: string;
153
- }
154
-
155
- interface DetoxTestRunnerConfig {
156
- args?: {
157
- /**
158
- * The command to use for runner: 'jest', 'nyc jest',
159
- */
160
- $0: string;
161
- /**
162
- * The positional arguments to pass to the runner.
163
- */
164
- _?: string[];
165
- /**
166
- * Any other properties recognized by test runner
167
- */
168
- [prop: string]: unknown;
169
- };
170
-
171
- /**
172
- * This is an add-on section used by our Jest integration code (but not Detox core itself).
173
- * In other words, if you’re implementing (or using) a custom integration with some other test runner, feel free to define a section for yourself (e.g. `testRunner.mocha`)
174
- */
175
- jest?: {
176
- /**
177
- * Environment setup timeout
178
- *
179
- * As a part of the environment setup, Detox boots the device and installs the apps.
180
- * If that takes longer than the specified value, the entire test suite will be considered as failed, e.g.:
181
- * ```plain text
182
- * FAIL e2e/starter.test.js
183
- * ● Test suite failed to run
184
- *
185
- * Exceeded timeout of 300000ms while setting up Detox environment
186
- * ```
187
- *
188
- * The default value is 5 minutes.
189
- *
190
- * @default 300000
191
- * @see {@link https://jestjs.io/docs/configuration/#testenvironment-string}
192
- */
193
- setupTimeout?: number | undefined;
194
- /**
195
- * Environemnt teardown timeout
196
- *
197
- * If the environment teardown takes longer than the specified value, Detox will throw a timeout error.
198
- * The default value is half a minute.
199
- *
200
- * @default 30000 (30 seconds)
201
- * @see {@link https://jestjs.io/docs/configuration/#testenvironment-string}
202
- */
203
- teardownTimeout?: number | undefined;
204
- /**
205
- * Jest provides an API to re-run individual failed tests: `jest.retryTimes(count)`.
206
- * When Detox detects the use of this API, it suppresses its own CLI retry mechanism controlled via `detox test … --retries <N>` or {@link DetoxTestRunnerConfig#retries}.
207
- * The motivation is simple – activating the both mechanisms is apt to increase your test duration dramatically, if your tests are flaky.
208
- * If you wish nevertheless to use both the mechanisms simultaneously, set it to `true`.
209
- *
210
- * @default false
211
- * @see {@link https://jestjs.io/docs/29.0/jest-object#jestretrytimesnumretries-options}
212
- */
213
- retryAfterCircusRetries?: boolean;
214
- /**
215
- * By default, Jest prints the test names and their status (_passed_ or _failed_) at the very end of the test session.
216
- * When enabled, it makes Detox to print messages like these each time the new test starts and ends:
217
- * ```plain text
218
- * 18:03:36.258 detox[40125] i Sanity: should have welcome screen
219
- * 18:03:37.495 detox[40125] i Sanity: should have welcome screen [OK]
220
- * 18:03:37.496 detox[40125] i Sanity: should show hello screen after tap
221
- * 18:03:38.928 detox[40125] i Sanity: should show hello screen after tap [OK]
222
- * 18:03:38.929 detox[40125] i Sanity: should show world screen after tap
223
- * 18:03:40.351 detox[40125] i Sanity: should show world screen after tap [OK]
224
- * ```
225
- * By default, it is enabled automatically in test sessions with a single worker.
226
- * And vice versa, if multiple tests are executed concurrently, Detox turns it off to avoid confusion in the log.
227
- * Use boolean values, `true` or `false`, to turn off the automatic choice.
228
- *
229
- * @default undefined
230
- */
231
- reportSpecs?: boolean | undefined;
232
- /**
233
- * In the environment setup phase, Detox boots the device and installs the apps.
234
- * This flag tells Detox to print messages like these every time the device gets assigned to a specific suite:
235
- *
236
- * ```plain text
237
- * 18:03:29.869 detox[40125] i starter.test.js is assigned to 4EC84833-C7EA-4CA3-A6E9-5C30A29EA596 (iPhone 12 Pro Max)
238
- * ```
239
- *
240
- * @default true
241
- */
242
- reportWorkerAssign?: boolean | undefined;
243
- };
244
- /**
245
- * Retries count. Zero means a single attempt to run tests.
246
- */
247
- retries?: number;
248
- /**
249
- * When true, tells Detox CLI to cancel next retrying if it gets
250
- * at least one report about a permanent test suite failure.
251
- * Has no effect, if {@link DetoxTestRunnerConfig#retries} is
252
- * undefined or set to zero.
253
- *
254
- * @default false
255
- * @see {DetoxInternals.DetoxTestFileReport#isPermanentFailure}
256
- */
257
- bail?: boolean;
258
- /**
259
- * Custom handler to process --inspect-brk CLI flag.
260
- * Use it when you rely on another test runner than Jest to mutate the config.
261
- */
262
- inspectBrk?: (config: DetoxTestRunnerConfig) => void;
263
- /**
264
- * Forward environment variables to the spawned test runner
265
- * accordingly to the given CLI argument overrides.
266
- *
267
- * If false, Detox CLI will be only printing a hint message on
268
- * how to start the test runner using environment variables,
269
- * in case when a user wants to avoid using Detox CLI.
270
- *
271
- * @default false
272
- */
273
- forwardEnv?: boolean;
274
- }
275
-
276
- type DetoxAppConfig = (DetoxBuiltInAppConfig | DetoxCustomAppConfig) & {
277
- /**
278
- * App name to use with device.selectApp(appName) calls.
279
- * Can be omitted if you have a single app under the test.
280
- *
281
- * @see Device#selectApp
282
- */
283
- name?: string;
284
- };
285
-
286
- type DetoxDeviceConfig = DetoxBuiltInDeviceConfig | DetoxCustomDriverConfig;
287
-
288
- interface DetoxLogArtifactsPluginConfig {
289
- enabled?: boolean;
290
- keepOnlyFailedTestsArtifacts?: boolean;
291
- }
292
-
293
- interface DetoxScreenshotArtifactsPluginConfig {
294
- enabled?: boolean;
295
- keepOnlyFailedTestsArtifacts?: boolean;
296
- shouldTakeAutomaticSnapshots?: boolean;
297
- takeWhen?: {
298
- testStart?: boolean;
299
- testFailure?: boolean;
300
- testDone?: boolean;
301
- appNotReady?: boolean;
302
- };
303
- }
304
-
305
- interface DetoxVideoArtifactsPluginConfig {
306
- enabled?: boolean;
307
- keepOnlyFailedTestsArtifacts?: boolean;
308
- android?: Partial<{
309
- size: [number, number];
310
- bitRate: number;
311
- timeLimit: number;
312
- verbose: boolean;
313
- }>;
314
- simulator?: Partial<{
315
- codec: string;
316
- }>;
317
- }
318
-
319
- interface DetoxInstrumentsArtifactsPluginConfig {
320
- enabled?: boolean;
321
- }
322
-
323
- interface DetoxUIHierarchyArtifactsPluginConfig {
324
- enabled?: boolean;
325
- }
326
-
327
- type DetoxBuiltInAppConfig = (DetoxIosAppConfig | DetoxAndroidAppConfig);
328
-
329
- interface DetoxIosAppConfig {
330
- type: 'ios.app';
331
- binaryPath: string;
332
- bundleId?: string;
333
- build?: string;
334
- start?: string;
335
- launchArgs?: Record<string, any>;
336
- }
337
-
338
- interface DetoxAndroidAppConfig {
339
- type: 'android.apk';
340
- binaryPath: string;
341
- bundleId?: string;
342
- build?: string;
343
- start?: string;
344
- testBinaryPath?: string;
345
- launchArgs?: Record<string, any>;
346
- /**
347
- * TCP ports to `adb reverse` upon the installation.
348
- * E.g. 8081 - to be able to access React Native packager in Debug mode.
349
- *
350
- * @example [8081]
351
- */
352
- reversePorts?: number[];
353
- }
354
-
355
- interface DetoxCustomAppConfig {
356
- type: string;
357
-
358
- [prop: string]: unknown;
359
- }
360
-
361
- type DetoxBuiltInDeviceConfig =
362
- | DetoxIosSimulatorDriverConfig
363
- | DetoxAttachedAndroidDriverConfig
364
- | DetoxAndroidEmulatorDriverConfig
365
- | DetoxGenymotionCloudDriverConfig;
366
-
367
- interface DetoxIosSimulatorDriverConfig {
368
- type: 'ios.simulator';
369
- device: string | Partial<IosSimulatorQuery>;
370
- bootArgs?: string;
371
- }
372
-
373
- interface DetoxSharedAndroidDriverConfig {
374
- forceAdbInstall?: boolean;
375
- utilBinaryPaths?: string[];
376
- }
377
-
378
- interface DetoxAttachedAndroidDriverConfig extends DetoxSharedAndroidDriverConfig {
379
- type: 'android.attached';
380
- device: string | { adbName: string };
381
- }
382
-
383
- interface DetoxAndroidEmulatorDriverConfig extends DetoxSharedAndroidDriverConfig {
384
- type: 'android.emulator';
385
- device: string | { avdName: string };
386
- bootArgs?: string;
387
- gpuMode?: 'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest' | 'off';
388
- headless?: boolean;
389
- /**
390
- * @default true
391
- */
392
- readonly?: boolean;
393
- }
394
-
395
- interface DetoxGenymotionCloudDriverConfig extends DetoxSharedAndroidDriverConfig {
396
- type: 'android.genycloud';
397
- device: string | { recipeUUID: string; } | { recipeName: string; };
398
- }
399
-
400
- interface DetoxCustomDriverConfig {
401
- type: string;
402
-
403
- [prop: string]: unknown;
404
- }
405
-
406
- interface IosSimulatorQuery {
407
- id: string;
408
- type: string;
409
- name: string;
410
- os: string;
411
- }
412
-
413
- type DetoxConfiguration = DetoxConfigurationCommon & (
414
- | DetoxConfigurationSingleApp
415
- | DetoxConfigurationMultiApps
416
- );
417
-
418
- interface DetoxConfigurationSingleApp {
419
- device: DetoxAliasedDevice;
420
- app: DetoxAliasedApp;
421
- }
422
-
423
- interface DetoxConfigurationMultiApps {
424
- device: DetoxAliasedDevice;
425
- apps: DetoxAliasedApp[];
426
- }
427
-
428
- type DetoxAliasedDevice = string | DetoxDeviceConfig;
429
-
430
- type DetoxAliasedApp = string | DetoxAppConfig;
431
-
432
- //#endregion
433
-
434
- interface DetoxExportWrapper {
435
- readonly device: Device;
436
-
437
- readonly element: ElementFacade;
438
-
439
- readonly waitFor: WaitForFacade;
440
-
441
- readonly expect: ExpectFacade;
442
-
443
- readonly by: ByFacade;
444
-
445
- readonly web: WebFacade;
446
-
447
- readonly DetoxConstants: {
448
- userNotificationTriggers: {
449
- push: 'push';
450
- calendar: 'calendar';
451
- timeInterval: 'timeInterval';
452
- location: 'location';
453
- };
454
- userActivityTypes: {
455
- searchableItem: string;
456
- browsingWeb: string;
457
- },
458
- searchableItemActivityIdentifier: string;
459
- };
460
-
461
- /**
462
- * Detox logger instance. Can be used for saving user logs to the general log file.
463
- */
464
- readonly log: Logger;
465
-
466
- /**
467
- * @deprecated
468
- *
469
- * Deprecated - use {@link Detox.Logger#trace}
470
- * Detox tracer instance. Can be used for building timelines in Google Event Tracing format.
471
- */
472
- readonly trace: {
473
- /** @deprecated */
474
- readonly startSection: (name: string) => void;
475
- /** @deprecated */
476
- readonly endSection: (name: string) => void;
477
- };
478
-
479
- /**
480
- * Trace a single call, with a given name and arguments.
481
- *
482
- * @deprecated
483
- * @param sectionName The name of the section to trace.
484
- * @param promiseOrFunction Promise or a function that provides a promise.
485
- * @param args Optional arguments to pass to the trace.
486
- * @returns The returned value of the traced call.
487
- * @see https://wix.github.io/Detox/docs/19.x/api/detox-object-api/#detoxtracecall
488
- */
489
- readonly traceCall: <T>(event: string, action: () => Promise<T>, args?: Record<string, unknown>) => Promise<T>;
490
- }
491
-
492
- interface Logger {
493
- readonly level: DetoxLogLevel;
494
-
495
- readonly fatal: _LogMethod;
496
- readonly error: _LogMethod;
497
- readonly warn: _LogMethod;
498
- readonly info: _LogMethod;
499
- readonly debug: _LogMethod;
500
- readonly trace: _LogMethod;
501
-
502
- child(context?: Partial<LogEvent>): Logger;
503
- }
504
-
505
- /** @internal */
506
- interface _LogMethod extends _LogMethodSignature {
507
- readonly begin: _LogMethodSignature;
508
- readonly complete: _CompleteMethodSignature;
509
- readonly end: _LogMethodSignature;
510
- }
511
-
512
- /** @internal */
513
- interface _LogMethodSignature {
514
- (...args: unknown[]): void
515
- (event: LogEvent, ...args: unknown[]): void;
516
- }
517
-
518
- /** @internal */
519
- interface _CompleteMethodSignature {
520
- <T>(message: string, action: T | (() => T)): T;
521
- <T>(event: LogEvent, message: string, action: T | (() => T)): T;
522
- }
523
-
524
- type LogEvent = {
525
- /** Use when there's a risk of logging several parallel duration events. */
526
- id?: string | number;
527
- /** Optional. Event categories (tags) to facilitate filtering. */
528
- cat?: string | string[];
529
- /** Optional. Color name (applicable in Google Chrome Trace Format) */
530
- cname?: string;
531
-
532
- /** Reserved property. Process ID. */
533
- pid?: never;
534
- /** Reserved property. Thread ID. */
535
- tid?: never;
536
- /** Reserved property. Timestamp. */
537
- ts?: never;
538
- /** Reserved property. Event phase. */
539
- ph?: never;
540
-
541
- [customProperty: string]: unknown;
542
- };
543
-
544
- type DetoxLogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
545
-
546
- type Point2D = {
547
- x: number,
548
- y: number,
549
- }
550
-
551
- /**
552
- * A construct allowing for the querying and modification of user arguments passed to an app upon launch by Detox.
553
- *
554
- * @see AppLaunchArgs#modify
555
- * @see AppLaunchArgs#reset
556
- * @see AppLaunchArgs#get
557
- */
558
- interface AppLaunchArgs {
559
- /**
560
- * Shared (global) arguments that are not specific to a particular application.
561
- * Selecting another app does not reset them, yet they still can be overridden
562
- * by configuring app-specific launch args.
563
- * @see Device#selectApp
564
- * @see AppLaunchArgs
565
- */
566
- readonly shared: ScopedAppLaunchArgs;
567
-
568
- /**
569
- * Modify the launch-arguments via a modifier object, according to the following logic:
570
- * - Non-nullish modifier properties would set a new value or override the previous value of
571
- * existing properties with the same name.
572
- * - Modifier properties set to either `undefined` or `null` would delete the corresponding property
573
- * if it existed.
574
- * These custom app launch arguments get erased whenever you select a different application.
575
- * If you need to share them between all the applications, use {@link AppLaunchArgs#shared} property.
576
- * Note: app-specific launch args have a priority over shared ones.
577
- *
578
- * @param modifier The modifier object.
579
- * @example
580
- * // With current launch arguments set to:
581
- * // {
582
- * // mockServerPort: 1234,
583
- * // mockServerCredentials: 'user@test.com:12345678',
584
- * // }
585
- * device.appLaunchArgs.modify({
586
- * mockServerPort: 4321,
587
- * mockServerCredentials: null,
588
- * mockServerToken: 'abcdef',
589
- * });
590
- * await device.launchApp();
591
- * // ==> launch-arguments become:
592
- * // {
593
- * // mockServerPort: 4321,
594
- * // mockServerToken: 'abcdef',
595
- * // }
596
- */
597
- modify(modifier: object): this;
598
-
599
- /**
600
- * Reset all app-specific launch arguments (back to an empty object).
601
- * If you need to reset the shared launch args, use {@link AppLaunchArgs#shared}.
602
- */
603
- reset(): this;
604
-
605
- /**
606
- * Get all currently set launch arguments (including shared ones).
607
- * @returns An object containing all launch-arguments.
608
- * Note: mutating the values inside the result object is pointless, as it is immutable.
609
- */
610
- get(): object;
611
- }
612
-
613
- /**
614
- * Shared (global) arguments that are not specific to a particular application.
615
- */
616
- interface ScopedAppLaunchArgs {
617
- /** @see AppLaunchArgs#modify */
618
- modify(modifier: object): this;
619
-
620
- /** @see AppLaunchArgs#reset */
621
- reset(): this;
622
-
623
- /** @see AppLaunchArgs#get */
624
- get(): object;
625
- }
626
-
627
- interface Device {
628
- /**
629
- * Holds the environment-unique ID of the device, namely, the adb ID on Android (e.g. emulator-5554) and the Mac-global simulator UDID on iOS -
630
- * as used by simctl (e.g. AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE).
631
- */
632
- id: string;
633
- /**
634
- * Holds a descriptive name of the device. Example: emulator-5554 (Pixel_API_29)
635
- */
636
- name: string;
637
-
638
- /**
639
- * Select the current app (relevant only to multi-app configs) by its name.
640
- * After execution, all app-specific device methods will target the selected app.
641
- *
642
- * @see DetoxAppConfig#name
643
- * @example
644
- * await device.selectApp('passenger');
645
- * await device.launchApp(); // passenger
646
- * // ... run tests for the passenger app
647
- * await device.uninstallApp(); // passenger
648
- * await device.selectApp('driver');
649
- * await device.installApp(); // driver
650
- * await device.launchApp(); // driver
651
- * // ... run tests for the driver app
652
- * await device.terminateApp(); // driver
653
- */
654
- selectApp(app: string): Promise<void>;
655
-
656
- /**
657
- * Launch the app.
658
- *
659
- * <p>For info regarding launch arguments, refer to the [dedicated guide](https://wix.github.io/Detox/docs/api/launch-args).
660
- *
661
- * @example
662
- * // Terminate the app and launch it again. If set to false, the simulator will try to bring app from background,
663
- * // if the app isn't running, it will launch a new instance. default is false
664
- * await device.launchApp({newInstance: true});
665
- * @example
666
- * // Grant or deny runtime permissions for your application.
667
- * await device.launchApp({permissions: {calendar: 'YES'}});
668
- * @example
669
- * // Mock opening the app from URL to test your app's deep link handling mechanism.
670
- * await device.launchApp({url: url});
671
- * @example
672
- * // Start the app with some custom arguments.
673
- * await device.launchApp({
674
- * launchArgs: {arg1: 1, arg2: "2"},
675
- * });
676
- */
677
- launchApp(config?: DeviceLaunchAppConfig): Promise<void>;
678
-
679
- /**
680
- * Relaunch the app. Convenience method that calls {@link Device#launchApp}
681
- * with { newInstance: true } override.
682
- *
683
- * @deprecated
684
- * @param config
685
- * @see Device#launchApp
686
- */
687
- relaunchApp(config?: DeviceLaunchAppConfig): Promise<void>;
688
-
689
- /**
690
- * Access the user-defined launch-arguments predefined through static scopes such as the Detox configuration file and
691
- * command-line arguments. This access allows - through dedicated methods, for both value-querying and
692
- * modification (see {@link AppLaunchArgs}).
693
- * Refer to the [dedicated guide](https://wix.github.io/Detox/docs/api/launch-args) for complete details.
694
- *
695
- * @example
696
- * // With Detox being preconfigured statically to use these arguments in app launch:
697
- * // {
698
- * // mockServerPort: 1234,
699
- * // }
700
- * // The following code would result in these arguments eventually passed into the launched app:
701
- * // {
702
- * // mockServerPort: 4321,
703
- * // mockServerToken: 'uvwxyz',
704
- * // }
705
- * device.appLaunchArgs.modify({
706
- * mockServerPort: 4321,
707
- * mockServerToken: 'abcdef',
708
- * });
709
- * await device.launchApp({ launchArgs: { mockServerToken: 'uvwxyz' } }};
710
- *
711
- * @see AppLaunchArgs
712
- */
713
- appLaunchArgs: AppLaunchArgs;
714
-
715
- /**
716
- * Terminate the app.
717
- *
718
- * @example
719
- * // By default, terminateApp() with no params will terminate the app
720
- * await device.terminateApp();
721
- * @example
722
- * // To terminate another app, specify its bundle id
723
- * await device.terminateApp('other.bundle.id');
724
- */
725
- terminateApp(bundle?: string): Promise<void>;
726
-
727
- /**
728
- * Send application to background by bringing com.apple.springboard to the foreground.
729
- * Combining sendToHome() with launchApp({newInstance: false}) will simulate app coming back from background.
730
- * @example
731
- * await device.sendToHome();
732
- * await device.launchApp({newInstance: false});
733
- */
734
- sendToHome(): Promise<void>;
735
-
736
- /**
737
- * If this is a React Native app, reload the React Native JS bundle. This action is much faster than device.launchApp(), and can be used if you just need to reset your React Native logic.
738
- *
739
- * @example await device.reloadReactNative()
740
- */
741
- reloadReactNative(): Promise<void>;
742
-
743
- /**
744
- * By default, installApp() with no params will install the app file defined in the current configuration.
745
- * To install another app, specify its path
746
- * @example await device.installApp();
747
- * @example await device.installApp('path/to/other/app');
748
- */
749
- installApp(path?: any): Promise<void>;
750
-
751
- /**
752
- * By default, uninstallApp() with no params will uninstall the app defined in the current configuration.
753
- * To uninstall another app, specify its bundle id
754
- * @example await device.installApp('other.bundle.id');
755
- */
756
- uninstallApp(bundle?: string): Promise<void>;
757
-
758
- /**
759
- * Mock opening the app from URL. sourceApp is an optional parameter to specify source application bundle id.
760
- */
761
- openURL(url: { url: string; sourceApp?: string }): Promise<void>;
762
-
763
- /**
764
- * Mock handling of received user notification when app is in foreground.
765
- */
766
- sendUserNotification(...params: any[]): Promise<void>;
767
-
768
- /**
769
- * Mock handling of received user activity when app is in foreground.
770
- */
771
- sendUserActivity(...params: any[]): Promise<void>;
772
-
773
- /**
774
- * Takes "portrait" or "landscape" and rotates the device to the given orientation. Currently only available in the iOS Simulator.
775
- */
776
- setOrientation(orientation: Orientation): Promise<void>;
777
-
778
- /**
779
- * Sets the simulator/emulator location to the given latitude and longitude.
780
- *
781
- * <p/>On iOS `setLocation` is dependent on [fbsimctl](https://github.com/facebook/idb/tree/4b7929480c3c0f158f33f78a5b802c1d0e7030d2/fbsimctl)
782
- * which [is now deprecated](https://github.com/wix/Detox/issues/1371).
783
- * If `fbsimctl` is not installed, the command will fail, asking for it to be installed.
784
- *
785
- * <p/>On Android `setLocation` will work with both Android Emulator (bundled with Android development tools) and Genymotion.
786
- * The correct permissions must be set in your app manifest.
787
- *
788
- * @example await device.setLocation(32.0853, 34.7818);
789
- */
790
- setLocation(lat: number, lon: number): Promise<void>;
791
-
792
- /**
793
- * Disable EarlGrey's network synchronization mechanism on preferred endpoints. Useful if you want to on skip over synchronizing on certain URLs.
794
- *
795
- * @example await device.setURLBlacklist(['.*127.0.0.1.*']);
796
- */
797
- setURLBlacklist(urls: string[]): Promise<void>;
798
-
799
- /**
800
- * Temporarily disable synchronization (idle/busy monitoring) with the app - namely, stop waiting for the app to go idle before moving forward in the test execution.
801
- *
802
- * <p/>This API is useful for cases where test assertions must be made in an area of your application where it is okay for it to ever remain partly *busy* (e.g. due to an
803
- * endlessly repeating on-screen animation). However, using it inherently suggests that you are likely to resort to applying `sleep()`'s in your test code - testing
804
- * that area, **which is not recommended and can never be 100% stable.
805
- * **Therefore, as a rule of thumb, test code running "inside" a sync-disabled mode must be reduced to the bare minimum.
806
- *
807
- * <p/>Note: Synchronization is enabled by default, and it gets **reenabled on every launch of a new instance of the app.**
808
- *
809
- * @example await device.disableSynchronization();
810
- */
811
- disableSynchronization(): Promise<void>;
812
-
813
- /**
814
- * Reenable synchronization (idle/busy monitoring) with the app - namely, resume waiting for the app to go idle before moving forward in the test execution, after a
815
- * previous disabling of it through a call to `device.disableSynchronization()`.
816
- *
817
- * <p/>Warning: Making this call would resume synchronization **instantly**, having its returned promise only resolve when the app becomes idle again.
818
- * In other words, this **must only be called after you navigate back to "the safe zone", where the app should be able to eventually become idle again**, or it would
819
- * remain suspended "forever" (i.e. until a safeguard time-out expires).
820
- *
821
- * @example await device.enableSynchronization();
822
- */
823
- enableSynchronization(): Promise<void>;
824
-
825
- /**
826
- * Resets the Simulator to clean state (like the Simulator > Reset Content and Settings... menu item), especially removing previously set permissions.
827
- *
828
- * @example await device.resetContentAndSettings();
829
- */
830
- resetContentAndSettings(): Promise<void>;
831
-
832
- /**
833
- * Returns the current device, ios or android.
834
- *
835
- * @example
836
- * if (device.getPlatform() === 'ios') {
837
- * await expect(loopSwitch).toHaveValue('1');
838
- * }
839
- */
840
- getPlatform(): 'ios' | 'android';
841
-
842
- /**
843
- * Takes a screenshot on the device and schedules putting it in the artifacts folder upon completion of the current test.
844
- * @param name for the screenshot artifact
845
- * @returns a temporary path to the screenshot.
846
- * @example
847
- * test('Menu items should have logout', async () => {
848
- * const tempPath = await device.takeScreenshot('tap on menu');
849
- * // The temporary path will remain valid until the test completion.
850
- * // Afterwards, the screenshot will be moved, e.g.:
851
- * // * on success, to: <artifacts-location>/✓ Menu items should have Logout/tap on menu.png
852
- * // * on failure, to: <artifacts-location>/✗ Menu items should have Logout/tap on menu.png
853
- * });
854
- */
855
- takeScreenshot(name: string): Promise<string>;
856
-
857
- /**
858
- * (iOS only) Saves a view hierarchy snapshot (*.viewhierarchy) of the currently opened application
859
- * to a temporary folder and schedules putting it to the artifacts folder upon the completion of
860
- * the current test. The file can be opened later in Xcode 12.0 and above.
861
- * @see https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes#:~:text=57933113
862
- * @param [name="capture"] optional name for the *.viewhierarchy artifact
863
- * @returns a temporary path to the captured view hierarchy snapshot.
864
- * @example
865
- * test('Menu items should have logout', async () => {
866
- * await device.captureViewHierarchy('myElements');
867
- * // The temporary path will remain valid until the test completion.
868
- * // Afterwards, the artifact will be moved, e.g.:
869
- * // * on success, to: <artifacts-location>/✓ Menu items should have Logout/myElements.viewhierarchy
870
- * // * on failure, to: <artifacts-location>/✗ Menu items should have Logout/myElements.viewhierarchy
871
- * });
872
- */
873
- captureViewHierarchy(name?: string): Promise<string>;
874
-
875
- /**
876
- * Simulate shake (iOS Only)
877
- */
878
- shake(): Promise<void>;
879
-
880
- /**
881
- * Toggles device enrollment in biometric auth (TouchID or FaceID) (iOS Only)
882
- * @example await device.setBiometricEnrollment(true);
883
- * @example await device.setBiometricEnrollment(false);
884
- */
885
- setBiometricEnrollment(enabled: boolean): Promise<void>;
886
-
887
- /**
888
- * Simulates the success of a face match via FaceID (iOS Only)
889
- */
890
- matchFace(): Promise<void>;
891
-
892
- /**
893
- * Simulates the failure of a face match via FaceID (iOS Only)
894
- */
895
- unmatchFace(): Promise<void>;
896
-
897
- /**
898
- * Simulates the success of a finger match via TouchID (iOS Only)
899
- */
900
- matchFinger(): Promise<void>;
901
-
902
- /**
903
- * Simulates the failure of a finger match via TouchID (iOS Only)
904
- */
905
- unmatchFinger(): Promise<void>;
906
-
907
- /**
908
- * Clears the simulator keychain (iOS Only)
909
- */
910
- clearKeychain(): Promise<void>;
911
-
912
- /**
913
- * Simulate press back button (Android Only)
914
- * @example await device.pressBack();
915
- */
916
- pressBack(): Promise<void>;
917
-
918
- /**
919
- * (Android Only)
920
- * Exposes UiAutomator's UiDevice API (https://developer.android.com/reference/android/support/test/uiautomator/UiDevice).
921
- * This is not a part of the official Detox API,
922
- * it may break and change whenever an update to UiDevice or UiAutomator gradle dependencies ('androidx.test.uiautomator:uiautomator') is introduced.
923
- * UIDevice's autogenerated code reference: https://github.com/wix/Detox/blob/master/detox/src/android/espressoapi/UIDevice.js
924
- */
925
- getUiDevice(): Promise<void>;
926
-
927
- /**
928
- * (Android Only)
929
- * Runs `adb reverse tcp:PORT tcp:PORT` for the current device
930
- * to enable network requests forwarding on localhost:PORT (computer<->device).
931
- * For more information, see {@link https://www.reddit.com/r/reactnative/comments/5etpqw/what_do_you_call_what_adb_reverse_is_doing|here}.
932
- * This is a no-op when running on iOS.
933
- */
934
- reverseTcpPort(port: number): Promise<void>;
935
-
936
- /**
937
- * (Android Only)
938
- * Runs `adb reverse --remove tcp:PORT tcp:PORT` for the current device
939
- * to disable network requests forwarding on localhost:PORT (computer<->device).
940
- * For more information, see {@link https://www.reddit.com/r/reactnative/comments/5etpqw/what_do_you_call_what_adb_reverse_is_doing|here}.
941
- * This is a no-op when running on iOS.
942
- */
943
- unreverseTcpPort(port: number): Promise<void>;
944
- }
945
-
946
- /**
947
- * @deprecated
948
- */
949
- type DetoxAny = NativeElement & WaitFor;
950
-
951
- interface ElementFacade {
952
- (by: NativeMatcher): IndexableNativeElement;
953
- }
954
-
955
- interface IndexableNativeElement extends NativeElement {
956
- /**
957
- * Choose from multiple elements matching the same matcher using index
958
- * @example await element(by.text('Product')).atIndex(2).tap();
959
- */
960
- atIndex(index: number): NativeElement;
961
- }
962
-
963
- interface NativeElement extends NativeElementActions {
964
- }
965
-
966
- interface ByFacade {
967
- /**
968
- * by.id will match an id that is given to the view via testID prop.
969
- * @example
970
- * // In a React Native component add testID like so:
971
- * <TouchableOpacity testID={'tap_me'}>
972
- * // Then match with by.id:
973
- * await element(by.id('tap_me'));
974
- */
975
- id(id: string): NativeMatcher;
976
-
977
- /**
978
- * Find an element by text, useful for text fields, buttons.
979
- * @example await element(by.text('Tap Me'));
980
- */
981
- text(text: string): NativeMatcher;
982
-
983
- /**
984
- * Find an element by accessibilityLabel on iOS, or by contentDescription on Android.
985
- * @example await element(by.label('Welcome'));
986
- */
987
- label(label: string): NativeMatcher;
988
-
989
- /**
990
- * Find an element by native view type.
991
- * @example await element(by.type('RCTImageView'));
992
- */
993
- type(nativeViewType: string): NativeMatcher;
994
-
995
- /**
996
- * Find an element with an accessibility trait. (iOS only)
997
- * @example await element(by.traits(['button']));
998
- */
999
- traits(traits: string[]): NativeMatcher;
1000
-
1001
- /**
1002
- * Collection of web matchers
1003
- */
1004
- readonly web: ByWebFacade;
1005
- }
1006
-
1007
- interface ByWebFacade {
1008
- /**
1009
- * Find an element on the DOM tree by its id
1010
- * @param id
1011
- * @example
1012
- * web.element(by.web.id('testingh1'))
1013
- */
1014
- id(id: string): WebMatcher;
1015
-
1016
- /**
1017
- * Find an element on the DOM tree by its CSS class
1018
- * @param className
1019
- * @example
1020
- * web.element(by.web.className('a'))
1021
- */
1022
- className(className: string): WebMatcher;
1023
-
1024
- /**
1025
- * Find an element on the DOM tree matching the given CSS selector
1026
- * @param cssSelector
1027
- * @example
1028
- * web.element(by.web.cssSelector('#cssSelector'))
1029
- */
1030
- cssSelector(cssSelector: string): WebMatcher;
1031
-
1032
- /**
1033
- * Find an element on the DOM tree by its "name" attribute
1034
- * @param name
1035
- * @example
1036
- * web.element(by.web.name('sec_input'))
1037
- */
1038
- name(name: string): WebMatcher;
1039
-
1040
- /**
1041
- * Find an element on the DOM tree by its XPath
1042
- * @param xpath
1043
- * @example
1044
- * web.element(by.web.xpath('//*[@id="testingh1-1"]'))
1045
- */
1046
- xpath(xpath: string): WebMatcher;
1047
-
1048
- /**
1049
- * Find an <a> element on the DOM tree by its link text (href content)
1050
- * @param linkText
1051
- * @example
1052
- * web.element(by.web.href('disney.com'))
1053
- */
1054
- href(linkText: string): WebMatcher;
1055
-
1056
- /**
1057
- * Find an <a> element on the DOM tree by its partial link text (href content)
1058
- * @param linkTextFragment
1059
- * @example
1060
- * web.element(by.web.hrefContains('disney'))
1061
- */
1062
- hrefContains(linkTextFragment: string): WebMatcher;
1063
-
1064
- /**
1065
- * Find an element on the DOM tree by its tag name
1066
- * @param tag
1067
- * @example
1068
- * web.element(by.web.tag('mark'))
1069
- */
1070
- tag(tagName: string): WebMatcher;
1071
- }
1072
-
1073
- interface NativeMatcher {
1074
- /**
1075
- * Find an element satisfying all the matchers
1076
- * @example await element(by.text('Product').and(by.id('product_name'));
1077
- */
1078
- and(by: NativeMatcher): NativeMatcher;
1079
-
1080
- /**
1081
- * Find an element by a matcher with a parent matcher
1082
- * @example await element(by.id('Grandson883').withAncestor(by.id('Son883')));
1083
- */
1084
- withAncestor(parentBy: NativeMatcher): NativeMatcher;
1085
-
1086
- /**
1087
- * Find an element by a matcher with a child matcher
1088
- * @example await element(by.id('Son883').withDescendant(by.id('Grandson883')));
1089
- */
1090
- withDescendant(childBy: NativeMatcher): NativeMatcher;
1091
- }
1092
-
1093
- interface WebMatcher {
1094
- __web__: any; // prevent type coersion
1095
- }
1096
-
1097
- interface ExpectFacade {
1098
- (element: NativeElement): Expect;
1099
-
1100
- (webElement: WebElement): WebExpect;
1101
- }
1102
-
1103
- interface WebViewElement {
1104
- element(webMatcher: WebMatcher): IndexableWebElement;
1105
- }
1106
-
1107
- interface WebFacade extends WebViewElement {
1108
- /**
1109
- * Gets the webview element as a testing element.
1110
- * @param matcher a simple view matcher for the webview element in th UI hierarchy.
1111
- * If there is only ONE webview element in the UI hierarchy, its NOT a must to supply it.
1112
- * If there are MORE then one webview element in the UI hierarchy you MUST supply are view matcher.
1113
- */
1114
- (matcher?: NativeMatcher): WebViewElement;
1115
- }
1116
-
1117
- interface Expect<R = Promise<void>> {
1118
-
1119
- /**
1120
- * Expect the view to be at least N% visible. If no number is provided then defaults to 75%. Negating this
1121
- * expectation with a `not` expects the view's visible area to be smaller than N%.
1122
- * @param pct optional integer ranging from 1 to 100, indicating how much percent of the view should be
1123
- * visible to the user to be accepted.
1124
- * @example await expect(element(by.id('mainTitle'))).toBeVisible(35);
1125
- */
1126
- toBeVisible(pct?: number): R;
1127
-
1128
- /**
1129
- * Negate the expectation.
1130
- * @example await expect(element(by.id('cancelButton'))).not.toBeVisible();
1131
- */
1132
- not: this;
1133
-
1134
- /**
1135
- * Expect the view to not be visible.
1136
- * @example await expect(element(by.id('cancelButton'))).toBeNotVisible();
1137
- * @deprecated Use `.not.toBeVisible()` instead.
1138
- */
1139
- toBeNotVisible(): R;
1140
-
1141
- /**
1142
- * Expect the view to exist in the UI hierarchy.
1143
- * @example await expect(element(by.id('okButton'))).toExist();
1144
- */
1145
- toExist(): R;
1146
-
1147
- /**
1148
- * Expect the view to not exist in the UI hierarchy.
1149
- * @example await expect(element(by.id('cancelButton'))).toNotExist();
1150
- * @deprecated Use `.not.toExist()` instead.
1151
- */
1152
- toNotExist(): R;
1153
-
1154
- /**
1155
- * Expect the view to be focused.
1156
- * @example await expect(element(by.id('emailInput'))).toBeFocused();
1157
- */
1158
- toBeFocused(): R;
1159
-
1160
- /**
1161
- * Expect the view not to be focused.
1162
- * @example await expect(element(by.id('passwordInput'))).toBeNotFocused();
1163
- * @deprecated Use `.not.toBeFocused()` instead.
1164
- */
1165
- toBeNotFocused(): R;
1166
-
1167
- /**
1168
- * In React Native apps, expect UI component of type <Text> to have text.
1169
- * In native iOS apps, expect UI elements of type UIButton, UILabel, UITextField or UITextViewIn to have inputText with text.
1170
- * @example await expect(element(by.id('mainTitle'))).toHaveText('Welcome back!);
1171
- */
1172
- toHaveText(text: string): R;
1173
-
1174
- /**
1175
- * Expects a specific accessibilityLabel, as specified via the `accessibilityLabel` prop in React Native.
1176
- * On the native side (in both React Native and pure-native apps), that is equivalent to `accessibilityLabel`
1177
- * on iOS and contentDescription on Android. Refer to Detox's documentation in order to learn about caveats
1178
- * with accessibility-labels in React Native apps.
1179
- * @example await expect(element(by.id('submitButton'))).toHaveLabel('Submit');
1180
- */
1181
- toHaveLabel(label: string): R;
1182
-
1183
- /**
1184
- * In React Native apps, expect UI component to have testID with that id.
1185
- * In native iOS apps, expect UI element to have accessibilityIdentifier with that id.
1186
- * @example await expect(element(by.text('Submit'))).toHaveId('submitButton');
1187
- */
1188
- toHaveId(id: string): R;
1189
-
1190
- /**
1191
- * Expects a toggle-able element (e.g. a Switch or a Check-Box) to be on/checked or off/unchecked.
1192
- * As a reference, in react-native, this is the equivalent switch component.
1193
- * @example await expect(element(by.id('switch'))).toHaveToggleValue(true);
1194
- */
1195
- toHaveToggleValue(value: boolean): R;
1196
-
1197
- /**
1198
- * Expect components like a Switch to have a value ('0' for off, '1' for on).
1199
- * @example await expect(element(by.id('temperatureDial'))).toHaveValue('25');
1200
- */
1201
- toHaveValue(value: any): R;
1202
-
1203
- /**
1204
- * Expect Slider to have a position (0 - 1).
1205
- * Can have an optional tolerance to take into account rounding issues on ios
1206
- * @example await expect(element(by.id('SliderId'))).toHavePosition(0.75);
1207
- * @example await expect(element(by.id('SliderId'))).toHavePosition(0.74, 0.1);
1208
- */
1209
- toHaveSliderPosition(position: number, tolerance?: number): Promise<void>;
1210
- }
1211
-
1212
- interface WaitForFacade {
1213
- /**
1214
- * This API polls using the given expectation continuously until the expectation is met. Use manual synchronization with waitFor only as a last resort.
1215
- * NOTE: Every waitFor call must set a timeout using withTimeout(). Calling waitFor without setting a timeout will do nothing.
1216
- * @example await waitFor(element(by.id('bigButton'))).toExist().withTimeout(2000);
1217
- */
1218
- (element: NativeElement): Expect<WaitFor>;
1219
- }
1220
-
1221
- interface WaitFor {
1222
- /**
1223
- * Waits for the condition to be met until the specified time (millis) have elapsed.
1224
- * @example await waitFor(element(by.id('bigButton'))).toExist().withTimeout(2000);
1225
- */
1226
- withTimeout(millis: number): Promise<void>;
1227
-
1228
- /**
1229
- * Performs the action repeatedly on the element until an expectation is met
1230
- * @example await waitFor(element(by.text('Item #5'))).toBeVisible().whileElement(by.id('itemsList')).scroll(50, 'down');
1231
- */
1232
- whileElement(by: NativeMatcher): NativeElement & WaitFor;
1233
-
1234
- // TODO: not sure about & WaitFor - check if we can chain whileElement multiple times
1235
- }
1236
-
1237
- interface NativeElementActions {
1238
- /**
1239
- * Simulate tap on an element
1240
- * @param point relative coordinates to the matched element (the element size could changes on different devices or even when changing the device font size)
1241
- * @example await element(by.id('tappable')).tap();
1242
- * @example await element(by.id('tappable')).tap({ x:5, y:10 });
1243
- */
1244
- tap(point?: Point2D): Promise<void>;
1245
-
1246
- /**
1247
- * Simulate long press on an element
1248
- * @param duration (iOS only) custom press duration time, in milliseconds. Optional (default is 1000ms).
1249
- * @example await element(by.id('tappable')).longPress();
1250
- */
1251
- longPress(duration?: number): Promise<void>;
1252
-
1253
- /**
1254
- * Simulate long press on an element and then drag it to the position of the target element. (iOS Only)
1255
- * @example await element(by.id('draggable')).longPressAndDrag(2000, NaN, NaN, element(by.id('target')), NaN, NaN, 'fast', 0);
1256
- */
1257
- longPressAndDrag(duration: number, normalizedPositionX: number, normalizedPositionY: number, targetElement: NativeElement,
1258
- normalizedTargetPositionX: number, normalizedTargetPositionY: number, speed: Speed, holdDuration: number): Promise<void>;
1259
-
1260
- /**
1261
- * Simulate multiple taps on an element.
1262
- * @param times number of times to tap
1263
- * @example await element(by.id('tappable')).multiTap(3);
1264
- */
1265
- multiTap(times: number): Promise<void>;
1266
-
1267
- /**
1268
- * Simulate tap at a specific point on an element.
1269
- * Note: The point coordinates are relative to the matched element and the element size could changes on different devices or even when changing the device font size.
1270
- * @example await element(by.id('tappable')).tapAtPoint({ x:5, y:10 });
1271
- * @deprecated Use `.tap()` instead.
1272
- */
1273
- tapAtPoint(point: Point2D): Promise<void>;
1274
-
1275
- /**
1276
- * Use the builtin keyboard to type text into a text field.
1277
- * @example await element(by.id('textField')).typeText('passcode');
1278
- */
1279
- typeText(text: string): Promise<void>;
1280
-
1281
- /**
1282
- * Paste text into a text field.
1283
- * @example await element(by.id('textField')).replaceText('passcode again');
1284
- */
1285
- replaceText(text: string): Promise<void>;
1286
-
1287
- /**
1288
- * Clear text from a text field.
1289
- * @example await element(by.id('textField')).clearText();
1290
- */
1291
- clearText(): Promise<void>;
1292
-
1293
- /**
1294
- * Taps the backspace key on the built-in keyboard.
1295
- * @example await element(by.id('textField')).tapBackspaceKey();
1296
- */
1297
- tapBackspaceKey(): Promise<void>;
1298
-
1299
- /**
1300
- * Taps the return key on the built-in keyboard.
1301
- * @example await element(by.id('textField')).tapReturnKey();
1302
- */
1303
- tapReturnKey(): Promise<void>;
1304
-
1305
- /**
1306
- * Scrolls a given amount of pixels in the provided direction, starting from the provided start positions.
1307
- * @param pixels - independent device pixels
1308
- * @param direction - left/right/up/down
1309
- * @param startPositionX - the X starting scroll position, in percentage; valid input: `[0.0, 1.0]`, `NaN`; default: `NaN`—choose the best value automatically
1310
- * @param startPositionY - the Y starting scroll position, in percentage; valid input: `[0.0, 1.0]`, `NaN`; default: `NaN`—choose the best value automatically
1311
- * @example await element(by.id('scrollView')).scroll(100, 'down', NaN, 0.85);
1312
- * @example await element(by.id('scrollView')).scroll(100, 'up');
1313
- */
1314
- scroll(
1315
- pixels: number,
1316
- direction: Direction,
1317
- startPositionX?: number,
1318
- startPositionY?: number
1319
- ): Promise<void>;
1320
-
1321
- /**
1322
- * Scroll to index.
1323
- * @example await element(by.id('scrollView')).scrollToIndex(10);
1324
- */
1325
- scrollToIndex(
1326
- index: Number
1327
- ): Promise<void>;
1328
-
1329
- /**
1330
- * Scroll to edge.
1331
- * @example await element(by.id('scrollView')).scrollTo('bottom');
1332
- * @example await element(by.id('scrollView')).scrollTo('top');
1333
- */
1334
- scrollTo(edge: Direction): Promise<void>;
1335
-
1336
- /**
1337
- * Adjust slider to position.
1338
- * @example await element(by.id('slider')).adjustSliderToPosition(0.75);
1339
- */
1340
- adjustSliderToPosition(newPosition: number): Promise<void>;
1341
-
1342
- /**
1343
- * Swipes in the provided direction at the provided speed, started from percentage.
1344
- * @param speed default: `fast`
1345
- * @param percentage screen percentage to swipe; valid input: `[0.0, 1.0]`
1346
- * @param optional normalizedStartingPointX X coordinate of swipe starting point, relative to the view width; valid input: `[0.0, 1.0]`
1347
- * @param normalizedStartingPointY Y coordinate of swipe starting point, relative to the view height; valid input: `[0.0, 1.0]`
1348
- * @example await element(by.id('scrollView')).swipe('down');
1349
- * @example await element(by.id('scrollView')).swipe('down', 'fast');
1350
- * @example await element(by.id('scrollView')).swipe('down', 'fast', 0.5);
1351
- * @example await element(by.id('scrollView')).swipe('down', 'fast', 0.5, 0.2);
1352
- * @example await element(by.id('scrollView')).swipe('down', 'fast', 0.5, 0.2, 0.5);
1353
- */
1354
- swipe(direction: Direction, speed?: Speed, percentage?: number, normalizedStartingPointX?: number, normalizedStartingPointY?: number): Promise<void>;
1355
-
1356
- /**
1357
- * Sets a picker view’s column to the given value. This function supports both date pickers and general picker views. (iOS Only)
1358
- * Note: When working with date pickers, you should always set an explicit locale when launching your app in order to prevent flakiness from different date and time styles.
1359
- * See [here](https://wix.github.io/Detox/docs/api/device-object-api#9-launch-with-a-specific-language-ios-only) for more information.
1360
- *
1361
- * @param column number of datepicker column (starts from 0)
1362
- * @param value string value in set column (must be correct)
1363
- * @example
1364
- * await expect(element(by.type('UIPickerView'))).toBeVisible();
1365
- * await element(by.type('UIPickerView')).setColumnToValue(1,"6");
1366
- * await element(by.type('UIPickerView')).setColumnToValue(2,"34");
1367
- */
1368
- setColumnToValue(column: number, value: string): Promise<void>;
1369
-
1370
- /**
1371
- * Sets the date of a date-picker according to the specified date-string and format.
1372
- * @param dateString Textual representation of a date (e.g. '2023/01/01'). Should be in coherence with the format specified by `dateFormat`.
1373
- * @param dateFormat Format of `dateString`: Generally either 'ISO8601' or an explicitly specified format (e.g. 'yyyy/MM/dd'); It should
1374
- * follow the rules of NSDateFormatter for iOS and DateTimeFormatter for Android.
1375
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
1376
- * @example
1377
- * await element(by.id('datePicker')).setDatePickerDate('2023-01-01T00:00:00Z', 'ISO8601');
1378
- * await element(by.id('datePicker')).setDatePickerDate(new Date().toISOString(), 'ISO8601');
1379
- * await element(by.id('datePicker')).setDatePickerDate('2023/01/01', 'yyyy/MM/dd');
1380
- */
1381
- setDatePickerDate(dateString: string, dateFormat: string): Promise<void>;
1382
-
1383
- /**
1384
- * Triggers a given [accessibility action]{@link https://reactnative.dev/docs/accessibility#accessibility-actions}.
1385
- * @param actionName - name of the accessibility action
1386
- * @example await element(by.id('view')).performAccessibilityAction('activate');
1387
- */
1388
- performAccessibilityAction(actionName: string): Promise<void>
1389
-
1390
- /**
1391
- * Pinches in the given direction with speed and angle. (iOS only)
1392
- * @param angle value in radiant, default is `0`
1393
- * @example
1394
- * await expect(element(by.id('PinchableScrollView'))).toBeVisible();
1395
- * await element(by.id('PinchableScrollView')).pinchWithAngle('outward', 'slow', 0);
1396
- * @deprecated Use `.pinch()` instead.
1397
- */
1398
- pinchWithAngle(direction: PinchDirection, speed: Speed, angle: number): Promise<void>;
1399
-
1400
- /**
1401
- * Pinches with the given scale, speed, and angle. (iOS only)
1402
- * @param speed default is `fast`
1403
- * @param angle value in radiant, default is `0`
1404
- * @example
1405
- * await element(by.id('PinchableScrollView')).pinch(1.1);
1406
- * await element(by.id('PinchableScrollView')).pinch(2.0);
1407
- * await element(by.id('PinchableScrollView')).pinch(0.001);
1408
- */
1409
- pinch(scale: number, speed?: Speed, angle?: number): Promise<void>;
1410
-
1411
- /**
1412
- * Takes a screenshot of the element and schedules putting it in the artifacts folder upon completion of the current test.
1413
- * For more information, see {@link https://wix.github.io/Detox/docs/api/screenshots#element-level-screenshots}
1414
- * @param {string} name for the screenshot artifact
1415
- * @returns {Promise<string>} a temporary path to the screenshot.
1416
- * @example
1417
- * test('Menu items should have logout', async () => {
1418
- * const imagePath = await element(by.id('menuRoot')).takeScreenshot('tap on menu');
1419
- * // The temporary path will remain valid until the test completion.
1420
- * // Afterwards, the screenshot will be moved, e.g.:
1421
- * // * on success, to: <artifacts-location>/✓ Menu items should have Logout/tap on menu.png
1422
- * // * on failure, to: <artifacts-location>/✗ Menu items should have Logout/tap on menu.png
1423
- * });
1424
- */
1425
- takeScreenshot(name: string): Promise<string>;
1426
-
1427
- /**
1428
- * Gets the native (OS-dependent) attributes of the element.
1429
- * For more information, see {@link https://wix.github.io/Detox/docs/api/actions-on-element/#getattributes}
1430
- *
1431
- * @example
1432
- * test('Get the attributes for my text element', async () => {
1433
- * const attributes = await element(by.id('myText')).getAttributes()
1434
- * const jestExpect = require('expect');
1435
- * // 'visible' attribute available on both iOS and Android
1436
- * jestExpect(attributes.visible).toBe(true);
1437
- * // 'activationPoint' attribute available on iOS only
1438
- * jestExpect(attributes.activationPoint.x).toHaveValue(50);
1439
- * // 'width' attribute available on Android only
1440
- * jestExpect(attributes.width).toHaveValue(100);
1441
- * })
1442
- */
1443
- getAttributes(): Promise<IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; }>;
1444
- }
1445
-
1446
- interface WebExpect<R = Promise<void>> {
1447
- /**
1448
- * Negate the expectation.
1449
- * @example await expect(web.element(by.web.id('sessionTimeout'))).not.toExist();
1450
- */
1451
- not: this;
1452
-
1453
- /**
1454
- * Expect the element content to have the `text` supplied
1455
- * @param text expected to be on the element content
1456
- * @example
1457
- * await expect(web.element(by.web.id('checkoutButton'))).toHaveText('Proceed to check out');
1458
- */
1459
- toHaveText(text: string): R;
1460
-
1461
- /**
1462
- * Expect the view to exist in the webview DOM tree.
1463
- * @example await expect(web.element(by.web.id('submitButton'))).toExist();
1464
- */
1465
- toExist(): R;
1466
- }
1467
-
1468
- interface IndexableWebElement extends WebElement {
1469
- /**
1470
- * Choose from multiple elements matching the same matcher using index
1471
- * @example await web.element(by.web.hrefContains('Details')).atIndex(2).tap();
1472
- */
1473
- atIndex(index: number): WebElement;
1474
- }
1475
-
1476
- interface WebElement extends WebElementActions {
1477
- }
1478
-
1479
- interface WebElementActions {
1480
- tap(): Promise<void>;
1481
-
1482
- /**
1483
- * @param text to type
1484
- * @param isContentEditable whether its a ContentEditable element, default is false.
1485
- */
1486
- typeText(text: string, isContentEditable: boolean): Promise<void>;
1487
-
1488
- /**
1489
- * At the moment not working on content-editable
1490
- * @param text to replace with the old content.
1491
- */
1492
- replaceText(text: string): Promise<void>;
1493
-
1494
- /**
1495
- * At the moment not working on content-editable
1496
- */
1497
- clearText(): Promise<void>;
1498
-
1499
- /**
1500
- * scrolling to the view, the element top position will be at the top of the screen.
1501
- */
1502
- scrollToView(): Promise<void>;
1503
-
1504
- /**
1505
- * Gets the input content
1506
- */
1507
- getText(): Promise<string>;
1508
-
1509
- /**
1510
- * Calls the focus function on the element
1511
- */
1512
- focus(): Promise<void>;
1513
-
1514
- /**
1515
- * Selects all the input content, works on ContentEditable at the moment.
1516
- */
1517
- selectAllText(): Promise<void>;
1518
-
1519
- /**
1520
- * Moves the input cursor / caret to the end of the content, works on ContentEditable at the moment.
1521
- */
1522
- moveCursorToEnd(): Promise<void>;
1523
-
1524
- /**
1525
- * Running a script on the element
1526
- * @param script a method that accept the element as its first arg
1527
- * @example function foo(element) { console.log(element); }
1528
- */
1529
- runScript(script: string): Promise<any>;
1530
-
1531
- /**
1532
- * Running a script on the element that accept args
1533
- * @param script a method that accept few args, and the element as the last arg.
1534
- * @param args a list of args to pass to the script
1535
- * @example function foo(a, b, c, element) { console.log(`${a}, ${b}, ${c}, ${element}`)}
1536
- */
1537
- runScriptWithArgs(script: string, args: any[]): Promise<any>;
1538
-
1539
- /**
1540
- * Gets the current page url
1541
- */
1542
- getCurrentUrl(): Promise<string>;
1543
-
1544
- /**
1545
- * Gets the current page title
1546
- */
1547
- getTitle(): Promise<string>;
1548
- }
1549
-
1550
- type Direction = 'left' | 'right' | 'top' | 'bottom' | 'up' | 'down';
1551
-
1552
- type PinchDirection = 'outward' | 'inward'
1553
-
1554
- type Orientation = 'portrait' | 'landscape';
1555
-
1556
- type Speed = 'fast' | 'slow';
1557
-
1558
- interface LanguageAndLocale {
1559
- language?: string;
1560
- locale?: string;
1561
- }
1562
-
1563
- /**
1564
- * Source for string definitions is https://github.com/wix/AppleSimulatorUtils
1565
- */
1566
- interface DevicePermissions {
1567
- location?: LocationPermission;
1568
- notifications?: NotificationsPermission;
1569
- calendar?: CalendarPermission;
1570
- camera?: CameraPermission;
1571
- contacts?: ContactsPermission;
1572
- health?: HealthPermission;
1573
- homekit?: HomekitPermission;
1574
- medialibrary?: MediaLibraryPermission;
1575
- microphone?: MicrophonePermission;
1576
- motion?: MotionPermission;
1577
- photos?: PhotosPermission;
1578
- reminders?: RemindersPermission;
1579
- siri?: SiriPermission;
1580
- speech?: SpeechPermission;
1581
- faceid?: FaceIDPermission;
1582
- userTracking?: UserTrackingPermission;
1583
- }
1584
-
1585
- type LocationPermission = 'always' | 'inuse' | 'never' | 'unset';
1586
- type PermissionState = 'YES' | 'NO' | 'unset';
1587
- type CameraPermission = PermissionState;
1588
- type ContactsPermission = PermissionState;
1589
- type CalendarPermission = PermissionState;
1590
- type HealthPermission = PermissionState;
1591
- type HomekitPermission = PermissionState;
1592
- type MediaLibraryPermission = PermissionState;
1593
- type MicrophonePermission = PermissionState;
1594
- type MotionPermission = PermissionState;
1595
- type PhotosPermission = PermissionState;
1596
- type RemindersPermission = PermissionState;
1597
- type SiriPermission = PermissionState;
1598
- type SpeechPermission = PermissionState;
1599
- type NotificationsPermission = PermissionState;
1600
- type FaceIDPermission = PermissionState;
1601
- type UserTrackingPermission = PermissionState;
1602
-
1603
- interface DeviceLaunchAppConfig {
1604
- /**
1605
- * Restart the app
1606
- * Terminate the app and launch it again. If set to false, the simulator will try to bring app from background, if the app isn't running, it will launch a new instance. default is false
1607
- */
1608
- newInstance?: boolean;
1609
- /**
1610
- * Set runtime permissions
1611
- * Grant or deny runtime permissions for your application.
1612
- */
1613
- permissions?: DevicePermissions;
1614
- /**
1615
- * Launch from URL
1616
- * Mock opening the app from URL to test your app's deep link handling mechanism.
1617
- */
1618
- url?: any;
1619
- /**
1620
- * Launch with user notifications
1621
- */
1622
- userNotification?: any;
1623
- /**
1624
- * Launch with user activity
1625
- */
1626
- userActivity?: any;
1627
- /**
1628
- * Launch into a fresh installation
1629
- * A flag that enables relaunching into a fresh installation of the app (it will uninstall and install the binary again), default is false.
1630
- */
1631
- delete?: boolean;
1632
- /**
1633
- * Arguments to pass-through into the app.
1634
- * Refer to the [dedicated guide](https://wix.github.io/Detox/docs/api/launch-args) for complete details.
1635
- */
1636
- launchArgs?: Record<string, any>;
1637
- /**
1638
- * Launch config for specifying the native language and locale
1639
- */
1640
- languageAndLocale?: LanguageAndLocale;
1641
- }
1642
-
1643
- // Element Attributes Shared Among iOS and Android
1644
- interface ElementAttributes {
1645
- /**
1646
- * Whether or not the element is enabled for user interaction.
1647
- */
1648
- enabled: boolean;
1649
- /**
1650
- * The identifier of the element. Matches accessibilityIdentifier on iOS, and the main view tag, on Android - both commonly holding the component's test ID in React Native apps.
1651
- */
1652
- identifier: string;
1653
- /**
1654
- * Whether the element is visible. On iOS, visibility is calculated for the activation point. On Android, the attribute directly holds the value returned by View.getLocalVisibleRect()).
1655
- */
1656
- visible: boolean;
1657
- /**
1658
- * The text value of any textual element.
1659
- */
1660
- text?: string;
1661
- /**
1662
- * The label of the element. Largely matches accessibilityLabel for ios, and contentDescription for android.
1663
- * Refer to Detox's documentation (`toHaveLabel()` subsection) in order to learn about caveats associated with
1664
- * this property in React Native apps.
1665
- */
1666
- label?: string;
1667
- /**
1668
- * The placeholder text value of the element. Matches hint on android.
1669
- */
1670
- placeholder?: string;
1671
- /**
1672
- * The value of the element, where applicable.
1673
- * Matches accessibilityValue, on iOS.
1674
- * For example: the position of a slider, or whether a checkbox has been marked (Android).
1675
- */
1676
- value?: unknown;
1677
- }
1678
-
1679
- interface IosElementAttributeFrame {
1680
- y: number;
1681
- x: number;
1682
- width: number;
1683
- height: number;
1684
- }
1685
-
1686
- interface IosElementAttributeInsets {
1687
- right: number;
1688
- top: number;
1689
- left: number;
1690
- bottom: number;
1691
- }
1692
-
1693
- // iOS Specific Attributes
1694
- interface IosElementAttributes extends ElementAttributes {
1695
- /**
1696
- * The [activation point]{@link https://developer.apple.com/documentation/objectivec/nsobject/1615179-accessibilityactivationpoint} of the element, in element coordinate space.
1697
- */
1698
- activationPoint: Point2D;
1699
- /**
1700
- * The activation point of the element, in normalized percentage ([0.0, 1.0]).
1701
- */
1702
- normalizedActivationPoint: Point2D;
1703
- /**
1704
- * Whether the element is hittable at the activation point.
1705
- */
1706
- hittable: boolean;
1707
- /**
1708
- * The frame of the element, in screen coordinate space.
1709
- */
1710
- frame: IosElementAttributeFrame;
1711
- /**
1712
- * The frame of the element, in container coordinate space.
1713
- */
1714
- elementFrame: IosElementAttributeFrame;
1715
- /**
1716
- * The bounds of the element, in element coordinate space.
1717
- */
1718
- elementBounds: IosElementAttributeFrame;
1719
- /**
1720
- * The safe area insets of the element, in element coordinate space.
1721
- */
1722
- safeAreaInsets: IosElementAttributeInsets;
1723
- /**
1724
- * The safe area bounds of the element, in element coordinate space.
1725
- */
1726
- elementSafeBounds: IosElementAttributeFrame;
1727
- /**
1728
- * The date of the element (if it is a date picker).
1729
- */
1730
- date?: string;
1731
- /**
1732
- * The normalized slider position (if it is a slider).
1733
- */
1734
- normalizedSliderPosition?: number;
1735
- /**
1736
- * The content offset (if it is a scroll view).
1737
- */
1738
- contentOffset?: Point2D;
1739
- /**
1740
- * The content inset (if it is a scroll view).
1741
- */
1742
- contentInset?: IosElementAttributeInsets;
1743
- /**
1744
- * The adjusted content inset (if it is a scroll view).
1745
- */
1746
- adjustedContentInset?: IosElementAttributeInsets;
1747
- /**
1748
- * @example "<CALayer: 0x600003f759e0>"
1749
- */
1750
- layer: string;
1751
- }
1752
-
1753
- // Android Specific Attributes
1754
- interface AndroidElementAttributes extends ElementAttributes {
1755
- /**
1756
- * The OS visibility type associated with the element: visible, invisible or gone.
1757
- */
1758
- visibility: 'visible' | 'invisible' | 'gone';
1759
- /**
1760
- * Width of the element, in pixels.
1761
- */
1762
- width: number;
1763
- /**
1764
- * Height of the element, in pixels.
1765
- */
1766
- height: number;
1767
- /**
1768
- * Elevation of the element.
1769
- */
1770
- elevation: number;
1771
- /**
1772
- * Alpha value for the element.
1773
- */
1774
- alpha: number;
1775
- /**
1776
- * Whether the element is the one currently in focus.
1777
- */
1778
- focused: boolean;
1779
- /**
1780
- * The text size for the text element.
1781
- */
1782
- textSize?: number;
1783
- /**
1784
- * The length of the text element (character count).
1785
- */
1786
- length?: number;
1787
- }
1788
- }
1789
- }
1
+ /// <reference path="detox.d.ts" />
2
+ /// <reference path="globals.d.ts" />
1790
3
 
1791
4
  declare const detox: Detox.DetoxExportWrapper;
1792
5
  export = detox;