@testing-library/react-native 14.0.0-rc.0 → 14.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/README.md +1 -6
  2. package/{build → dist}/helpers/accessibility.js +24 -7
  3. package/dist/helpers/accessibility.js.map +1 -0
  4. package/docs/README.md +31 -0
  5. package/docs/api/accessibility.md +26 -0
  6. package/docs/api/async-utilities.md +137 -0
  7. package/docs/api/configuration.md +61 -0
  8. package/docs/api/fire-event.md +165 -0
  9. package/docs/api/jest-matchers.md +198 -0
  10. package/docs/api/other-helpers.md +94 -0
  11. package/docs/api/overview.md +18 -0
  12. package/docs/api/queries.md +500 -0
  13. package/docs/api/render-hook.md +176 -0
  14. package/docs/api/render.md +49 -0
  15. package/docs/api/screen.md +188 -0
  16. package/docs/api/user-event.md +295 -0
  17. package/docs/cookbook/async-events.md +147 -0
  18. package/docs/cookbook/custom-render.md +83 -0
  19. package/docs/cookbook/network-requests.md +375 -0
  20. package/docs/guides/common-mistakes.md +587 -0
  21. package/docs/guides/how-to-query.md +125 -0
  22. package/docs/guides/llm-guidelines.md +228 -0
  23. package/docs/guides/migration-v14.md +553 -0
  24. package/docs/guides/quick-start.md +77 -0
  25. package/docs/guides/testing-environment.md +123 -0
  26. package/docs/guides/troubleshooting.md +61 -0
  27. package/docs/guides/understanding-act.md +207 -0
  28. package/matchers.d.ts +1 -1
  29. package/matchers.js +2 -2
  30. package/package.json +14 -12
  31. package/pure.d.ts +1 -1
  32. package/pure.js +1 -1
  33. package/build/helpers/accessibility.js.map +0 -1
  34. /package/{build → dist}/act.d.ts +0 -0
  35. /package/{build → dist}/act.js +0 -0
  36. /package/{build → dist}/act.js.map +0 -0
  37. /package/{build → dist}/cleanup.d.ts +0 -0
  38. /package/{build → dist}/cleanup.js +0 -0
  39. /package/{build → dist}/cleanup.js.map +0 -0
  40. /package/{build → dist}/config.d.ts +0 -0
  41. /package/{build → dist}/config.js +0 -0
  42. /package/{build → dist}/config.js.map +0 -0
  43. /package/{build → dist}/event-builder/base.d.ts +0 -0
  44. /package/{build → dist}/event-builder/base.js +0 -0
  45. /package/{build → dist}/event-builder/base.js.map +0 -0
  46. /package/{build → dist}/event-builder/common.d.ts +0 -0
  47. /package/{build → dist}/event-builder/common.js +0 -0
  48. /package/{build → dist}/event-builder/common.js.map +0 -0
  49. /package/{build → dist}/event-builder/index.d.ts +0 -0
  50. /package/{build → dist}/event-builder/index.js +0 -0
  51. /package/{build → dist}/event-builder/index.js.map +0 -0
  52. /package/{build → dist}/event-builder/scroll.d.ts +0 -0
  53. /package/{build → dist}/event-builder/scroll.js +0 -0
  54. /package/{build → dist}/event-builder/scroll.js.map +0 -0
  55. /package/{build → dist}/event-builder/text.d.ts +0 -0
  56. /package/{build → dist}/event-builder/text.js +0 -0
  57. /package/{build → dist}/event-builder/text.js.map +0 -0
  58. /package/{build → dist}/event-handler.d.ts +0 -0
  59. /package/{build → dist}/event-handler.js +0 -0
  60. /package/{build → dist}/event-handler.js.map +0 -0
  61. /package/{build → dist}/fire-event.d.ts +0 -0
  62. /package/{build → dist}/fire-event.js +0 -0
  63. /package/{build → dist}/fire-event.js.map +0 -0
  64. /package/{build → dist}/flush-micro-tasks.d.ts +0 -0
  65. /package/{build → dist}/flush-micro-tasks.js +0 -0
  66. /package/{build → dist}/flush-micro-tasks.js.map +0 -0
  67. /package/{build → dist}/helpers/accessibility.d.ts +0 -0
  68. /package/{build → dist}/helpers/component-tree.d.ts +0 -0
  69. /package/{build → dist}/helpers/component-tree.js +0 -0
  70. /package/{build → dist}/helpers/component-tree.js.map +0 -0
  71. /package/{build → dist}/helpers/debug.d.ts +0 -0
  72. /package/{build → dist}/helpers/debug.js +0 -0
  73. /package/{build → dist}/helpers/debug.js.map +0 -0
  74. /package/{build → dist}/helpers/errors.d.ts +0 -0
  75. /package/{build → dist}/helpers/errors.js +0 -0
  76. /package/{build → dist}/helpers/errors.js.map +0 -0
  77. /package/{build → dist}/helpers/find-all.d.ts +0 -0
  78. /package/{build → dist}/helpers/find-all.js +0 -0
  79. /package/{build → dist}/helpers/find-all.js.map +0 -0
  80. /package/{build → dist}/helpers/format-element.d.ts +0 -0
  81. /package/{build → dist}/helpers/format-element.js +0 -0
  82. /package/{build → dist}/helpers/format-element.js.map +0 -0
  83. /package/{build → dist}/helpers/host-component-names.d.ts +0 -0
  84. /package/{build → dist}/helpers/host-component-names.js +0 -0
  85. /package/{build → dist}/helpers/host-component-names.js.map +0 -0
  86. /package/{build → dist}/helpers/logger.d.ts +0 -0
  87. /package/{build → dist}/helpers/logger.js +0 -0
  88. /package/{build → dist}/helpers/logger.js.map +0 -0
  89. /package/{build → dist}/helpers/map-props.d.ts +0 -0
  90. /package/{build → dist}/helpers/map-props.js +0 -0
  91. /package/{build → dist}/helpers/map-props.js.map +0 -0
  92. /package/{build → dist}/helpers/matchers/match-accessibility-state.d.ts +0 -0
  93. /package/{build → dist}/helpers/matchers/match-accessibility-state.js +0 -0
  94. /package/{build → dist}/helpers/matchers/match-accessibility-state.js.map +0 -0
  95. /package/{build → dist}/helpers/matchers/match-accessibility-value.d.ts +0 -0
  96. /package/{build → dist}/helpers/matchers/match-accessibility-value.js +0 -0
  97. /package/{build → dist}/helpers/matchers/match-accessibility-value.js.map +0 -0
  98. /package/{build → dist}/helpers/matchers/match-array-prop.d.ts +0 -0
  99. /package/{build → dist}/helpers/matchers/match-array-prop.js +0 -0
  100. /package/{build → dist}/helpers/matchers/match-array-prop.js.map +0 -0
  101. /package/{build → dist}/helpers/matchers/match-label-text.d.ts +0 -0
  102. /package/{build → dist}/helpers/matchers/match-label-text.js +0 -0
  103. /package/{build → dist}/helpers/matchers/match-label-text.js.map +0 -0
  104. /package/{build → dist}/helpers/matchers/match-object-prop.d.ts +0 -0
  105. /package/{build → dist}/helpers/matchers/match-object-prop.js +0 -0
  106. /package/{build → dist}/helpers/matchers/match-object-prop.js.map +0 -0
  107. /package/{build → dist}/helpers/matchers/match-string-prop.d.ts +0 -0
  108. /package/{build → dist}/helpers/matchers/match-string-prop.js +0 -0
  109. /package/{build → dist}/helpers/matchers/match-string-prop.js.map +0 -0
  110. /package/{build → dist}/helpers/matchers/match-text-content.d.ts +0 -0
  111. /package/{build → dist}/helpers/matchers/match-text-content.js +0 -0
  112. /package/{build → dist}/helpers/matchers/match-text-content.js.map +0 -0
  113. /package/{build → dist}/helpers/object.d.ts +0 -0
  114. /package/{build → dist}/helpers/object.js +0 -0
  115. /package/{build → dist}/helpers/object.js.map +0 -0
  116. /package/{build → dist}/helpers/pointer-events.d.ts +0 -0
  117. /package/{build → dist}/helpers/pointer-events.js +0 -0
  118. /package/{build → dist}/helpers/pointer-events.js.map +0 -0
  119. /package/{build → dist}/helpers/text-content.d.ts +0 -0
  120. /package/{build → dist}/helpers/text-content.js +0 -0
  121. /package/{build → dist}/helpers/text-content.js.map +0 -0
  122. /package/{build → dist}/helpers/text-input.d.ts +0 -0
  123. /package/{build → dist}/helpers/text-input.js +0 -0
  124. /package/{build → dist}/helpers/text-input.js.map +0 -0
  125. /package/{build → dist}/helpers/timers.d.ts +0 -0
  126. /package/{build → dist}/helpers/timers.js +0 -0
  127. /package/{build → dist}/helpers/timers.js.map +0 -0
  128. /package/{build → dist}/helpers/validate-options.d.ts +0 -0
  129. /package/{build → dist}/helpers/validate-options.js +0 -0
  130. /package/{build → dist}/helpers/validate-options.js.map +0 -0
  131. /package/{build → dist}/helpers/wrap-async.d.ts +0 -0
  132. /package/{build → dist}/helpers/wrap-async.js +0 -0
  133. /package/{build → dist}/helpers/wrap-async.js.map +0 -0
  134. /package/{build → dist}/index.d.ts +0 -0
  135. /package/{build → dist}/index.js +0 -0
  136. /package/{build → dist}/index.js.map +0 -0
  137. /package/{build → dist}/matchers/extend-expect.d.ts +0 -0
  138. /package/{build → dist}/matchers/extend-expect.js +0 -0
  139. /package/{build → dist}/matchers/extend-expect.js.map +0 -0
  140. /package/{build → dist}/matchers/index.d.ts +0 -0
  141. /package/{build → dist}/matchers/index.js +0 -0
  142. /package/{build → dist}/matchers/index.js.map +0 -0
  143. /package/{build → dist}/matchers/to-be-busy.d.ts +0 -0
  144. /package/{build → dist}/matchers/to-be-busy.js +0 -0
  145. /package/{build → dist}/matchers/to-be-busy.js.map +0 -0
  146. /package/{build → dist}/matchers/to-be-checked.d.ts +0 -0
  147. /package/{build → dist}/matchers/to-be-checked.js +0 -0
  148. /package/{build → dist}/matchers/to-be-checked.js.map +0 -0
  149. /package/{build → dist}/matchers/to-be-disabled.d.ts +0 -0
  150. /package/{build → dist}/matchers/to-be-disabled.js +0 -0
  151. /package/{build → dist}/matchers/to-be-disabled.js.map +0 -0
  152. /package/{build → dist}/matchers/to-be-empty-element.d.ts +0 -0
  153. /package/{build → dist}/matchers/to-be-empty-element.js +0 -0
  154. /package/{build → dist}/matchers/to-be-empty-element.js.map +0 -0
  155. /package/{build → dist}/matchers/to-be-expanded.d.ts +0 -0
  156. /package/{build → dist}/matchers/to-be-expanded.js +0 -0
  157. /package/{build → dist}/matchers/to-be-expanded.js.map +0 -0
  158. /package/{build → dist}/matchers/to-be-on-the-screen.d.ts +0 -0
  159. /package/{build → dist}/matchers/to-be-on-the-screen.js +0 -0
  160. /package/{build → dist}/matchers/to-be-on-the-screen.js.map +0 -0
  161. /package/{build → dist}/matchers/to-be-partially-checked.d.ts +0 -0
  162. /package/{build → dist}/matchers/to-be-partially-checked.js +0 -0
  163. /package/{build → dist}/matchers/to-be-partially-checked.js.map +0 -0
  164. /package/{build → dist}/matchers/to-be-selected.d.ts +0 -0
  165. /package/{build → dist}/matchers/to-be-selected.js +0 -0
  166. /package/{build → dist}/matchers/to-be-selected.js.map +0 -0
  167. /package/{build → dist}/matchers/to-be-visible.d.ts +0 -0
  168. /package/{build → dist}/matchers/to-be-visible.js +0 -0
  169. /package/{build → dist}/matchers/to-be-visible.js.map +0 -0
  170. /package/{build → dist}/matchers/to-contain-element.d.ts +0 -0
  171. /package/{build → dist}/matchers/to-contain-element.js +0 -0
  172. /package/{build → dist}/matchers/to-contain-element.js.map +0 -0
  173. /package/{build → dist}/matchers/to-have-accessibility-value.d.ts +0 -0
  174. /package/{build → dist}/matchers/to-have-accessibility-value.js +0 -0
  175. /package/{build → dist}/matchers/to-have-accessibility-value.js.map +0 -0
  176. /package/{build → dist}/matchers/to-have-accessible-name.d.ts +0 -0
  177. /package/{build → dist}/matchers/to-have-accessible-name.js +0 -0
  178. /package/{build → dist}/matchers/to-have-accessible-name.js.map +0 -0
  179. /package/{build → dist}/matchers/to-have-display-value.d.ts +0 -0
  180. /package/{build → dist}/matchers/to-have-display-value.js +0 -0
  181. /package/{build → dist}/matchers/to-have-display-value.js.map +0 -0
  182. /package/{build → dist}/matchers/to-have-prop.d.ts +0 -0
  183. /package/{build → dist}/matchers/to-have-prop.js +0 -0
  184. /package/{build → dist}/matchers/to-have-prop.js.map +0 -0
  185. /package/{build → dist}/matchers/to-have-style.d.ts +0 -0
  186. /package/{build → dist}/matchers/to-have-style.js +0 -0
  187. /package/{build → dist}/matchers/to-have-style.js.map +0 -0
  188. /package/{build → dist}/matchers/to-have-text-content.d.ts +0 -0
  189. /package/{build → dist}/matchers/to-have-text-content.js +0 -0
  190. /package/{build → dist}/matchers/to-have-text-content.js.map +0 -0
  191. /package/{build → dist}/matchers/types.d.ts +0 -0
  192. /package/{build → dist}/matchers/types.js +0 -0
  193. /package/{build → dist}/matchers/types.js.map +0 -0
  194. /package/{build → dist}/matchers/utils.d.ts +0 -0
  195. /package/{build → dist}/matchers/utils.js +0 -0
  196. /package/{build → dist}/matchers/utils.js.map +0 -0
  197. /package/{build → dist}/matches.d.ts +0 -0
  198. /package/{build → dist}/matches.js +0 -0
  199. /package/{build → dist}/matches.js.map +0 -0
  200. /package/{build → dist}/native-state.d.ts +0 -0
  201. /package/{build → dist}/native-state.js +0 -0
  202. /package/{build → dist}/native-state.js.map +0 -0
  203. /package/{build → dist}/pure.d.ts +0 -0
  204. /package/{build → dist}/pure.js +0 -0
  205. /package/{build → dist}/pure.js.map +0 -0
  206. /package/{build → dist}/queries/display-value.d.ts +0 -0
  207. /package/{build → dist}/queries/display-value.js +0 -0
  208. /package/{build → dist}/queries/display-value.js.map +0 -0
  209. /package/{build → dist}/queries/hint-text.d.ts +0 -0
  210. /package/{build → dist}/queries/hint-text.js +0 -0
  211. /package/{build → dist}/queries/hint-text.js.map +0 -0
  212. /package/{build → dist}/queries/label-text.d.ts +0 -0
  213. /package/{build → dist}/queries/label-text.js +0 -0
  214. /package/{build → dist}/queries/label-text.js.map +0 -0
  215. /package/{build → dist}/queries/make-queries.d.ts +0 -0
  216. /package/{build → dist}/queries/make-queries.js +0 -0
  217. /package/{build → dist}/queries/make-queries.js.map +0 -0
  218. /package/{build → dist}/queries/options.d.ts +0 -0
  219. /package/{build → dist}/queries/options.js +0 -0
  220. /package/{build → dist}/queries/options.js.map +0 -0
  221. /package/{build → dist}/queries/placeholder-text.d.ts +0 -0
  222. /package/{build → dist}/queries/placeholder-text.js +0 -0
  223. /package/{build → dist}/queries/placeholder-text.js.map +0 -0
  224. /package/{build → dist}/queries/role.d.ts +0 -0
  225. /package/{build → dist}/queries/role.js +0 -0
  226. /package/{build → dist}/queries/role.js.map +0 -0
  227. /package/{build → dist}/queries/test-id.d.ts +0 -0
  228. /package/{build → dist}/queries/test-id.js +0 -0
  229. /package/{build → dist}/queries/test-id.js.map +0 -0
  230. /package/{build → dist}/queries/text.d.ts +0 -0
  231. /package/{build → dist}/queries/text.js +0 -0
  232. /package/{build → dist}/queries/text.js.map +0 -0
  233. /package/{build → dist}/render-hook.d.ts +0 -0
  234. /package/{build → dist}/render-hook.js +0 -0
  235. /package/{build → dist}/render-hook.js.map +0 -0
  236. /package/{build → dist}/render.d.ts +0 -0
  237. /package/{build → dist}/render.js +0 -0
  238. /package/{build → dist}/render.js.map +0 -0
  239. /package/{build → dist}/screen.d.ts +0 -0
  240. /package/{build → dist}/screen.js +0 -0
  241. /package/{build → dist}/screen.js.map +0 -0
  242. /package/{build → dist}/test-utils/console.d.ts +0 -0
  243. /package/{build → dist}/test-utils/console.js +0 -0
  244. /package/{build → dist}/test-utils/console.js.map +0 -0
  245. /package/{build → dist}/test-utils/events.d.ts +0 -0
  246. /package/{build → dist}/test-utils/events.js +0 -0
  247. /package/{build → dist}/test-utils/events.js.map +0 -0
  248. /package/{build → dist}/test-utils/json.d.ts +0 -0
  249. /package/{build → dist}/test-utils/json.js +0 -0
  250. /package/{build → dist}/test-utils/json.js.map +0 -0
  251. /package/{build → dist}/test-utils/react-version-gates.d.ts +0 -0
  252. /package/{build → dist}/test-utils/react-version-gates.js +0 -0
  253. /package/{build → dist}/test-utils/react-version-gates.js.map +0 -0
  254. /package/{build → dist}/test-utils/timers.d.ts +0 -0
  255. /package/{build → dist}/test-utils/timers.js +0 -0
  256. /package/{build → dist}/test-utils/timers.js.map +0 -0
  257. /package/{build → dist}/test-utils/version.d.ts +0 -0
  258. /package/{build → dist}/test-utils/version.js +0 -0
  259. /package/{build → dist}/test-utils/version.js.map +0 -0
  260. /package/{build → dist}/types.d.ts +0 -0
  261. /package/{build → dist}/types.js +0 -0
  262. /package/{build → dist}/types.js.map +0 -0
  263. /package/{build → dist}/user-event/clear.d.ts +0 -0
  264. /package/{build → dist}/user-event/clear.js +0 -0
  265. /package/{build → dist}/user-event/clear.js.map +0 -0
  266. /package/{build → dist}/user-event/index.d.ts +0 -0
  267. /package/{build → dist}/user-event/index.js +0 -0
  268. /package/{build → dist}/user-event/index.js.map +0 -0
  269. /package/{build → dist}/user-event/paste.d.ts +0 -0
  270. /package/{build → dist}/user-event/paste.js +0 -0
  271. /package/{build → dist}/user-event/paste.js.map +0 -0
  272. /package/{build → dist}/user-event/press/index.d.ts +0 -0
  273. /package/{build → dist}/user-event/press/index.js +0 -0
  274. /package/{build → dist}/user-event/press/index.js.map +0 -0
  275. /package/{build → dist}/user-event/press/press.d.ts +0 -0
  276. /package/{build → dist}/user-event/press/press.js +0 -0
  277. /package/{build → dist}/user-event/press/press.js.map +0 -0
  278. /package/{build → dist}/user-event/scroll/index.d.ts +0 -0
  279. /package/{build → dist}/user-event/scroll/index.js +0 -0
  280. /package/{build → dist}/user-event/scroll/index.js.map +0 -0
  281. /package/{build → dist}/user-event/scroll/scroll-to.d.ts +0 -0
  282. /package/{build → dist}/user-event/scroll/scroll-to.js +0 -0
  283. /package/{build → dist}/user-event/scroll/scroll-to.js.map +0 -0
  284. /package/{build → dist}/user-event/scroll/utils.d.ts +0 -0
  285. /package/{build → dist}/user-event/scroll/utils.js +0 -0
  286. /package/{build → dist}/user-event/scroll/utils.js.map +0 -0
  287. /package/{build → dist}/user-event/setup/index.d.ts +0 -0
  288. /package/{build → dist}/user-event/setup/index.js +0 -0
  289. /package/{build → dist}/user-event/setup/index.js.map +0 -0
  290. /package/{build → dist}/user-event/setup/setup.d.ts +0 -0
  291. /package/{build → dist}/user-event/setup/setup.js +0 -0
  292. /package/{build → dist}/user-event/setup/setup.js.map +0 -0
  293. /package/{build → dist}/user-event/type/index.d.ts +0 -0
  294. /package/{build → dist}/user-event/type/index.js +0 -0
  295. /package/{build → dist}/user-event/type/index.js.map +0 -0
  296. /package/{build → dist}/user-event/type/parse-keys.d.ts +0 -0
  297. /package/{build → dist}/user-event/type/parse-keys.js +0 -0
  298. /package/{build → dist}/user-event/type/parse-keys.js.map +0 -0
  299. /package/{build → dist}/user-event/type/type.d.ts +0 -0
  300. /package/{build → dist}/user-event/type/type.js +0 -0
  301. /package/{build → dist}/user-event/type/type.js.map +0 -0
  302. /package/{build → dist}/user-event/utils/content-size.d.ts +0 -0
  303. /package/{build → dist}/user-event/utils/content-size.js +0 -0
  304. /package/{build → dist}/user-event/utils/content-size.js.map +0 -0
  305. /package/{build → dist}/user-event/utils/dispatch-event.d.ts +0 -0
  306. /package/{build → dist}/user-event/utils/dispatch-event.js +0 -0
  307. /package/{build → dist}/user-event/utils/dispatch-event.js.map +0 -0
  308. /package/{build → dist}/user-event/utils/index.d.ts +0 -0
  309. /package/{build → dist}/user-event/utils/index.js +0 -0
  310. /package/{build → dist}/user-event/utils/index.js.map +0 -0
  311. /package/{build → dist}/user-event/utils/wait.d.ts +0 -0
  312. /package/{build → dist}/user-event/utils/wait.js +0 -0
  313. /package/{build → dist}/user-event/utils/wait.js.map +0 -0
  314. /package/{build → dist}/wait-for-element-to-be-removed.d.ts +0 -0
  315. /package/{build → dist}/wait-for-element-to-be-removed.js +0 -0
  316. /package/{build → dist}/wait-for-element-to-be-removed.js.map +0 -0
  317. /package/{build → dist}/wait-for.d.ts +0 -0
  318. /package/{build → dist}/wait-for.js +0 -0
  319. /package/{build → dist}/wait-for.js.map +0 -0
  320. /package/{build → dist}/within.d.ts +0 -0
  321. /package/{build → dist}/within.js +0 -0
  322. /package/{build → dist}/within.js.map +0 -0
@@ -0,0 +1,123 @@
1
+ # Testing environment
2
+
3
+ > [!INFO]
4
+ > This document is intended for a more advanced audience who want to understand the internals of our testing environment better, e.g., to contribute to the codebase. You should be able to write integration or component tests without reading this.
5
+
6
+ React Native Testing Library lets you write integration and component tests for your React Native app or library. While the JSX code in tests closely resembles your React Native app, the underlying environment differs. This document describes the key elements of our testing environment and highlights things to be aware of when writing advanced tests or diagnosing issues.
7
+
8
+ ## React renderers
9
+
10
+ React allows you to write declarative code using JSX, write function or class components, or use hooks like `useState`. You need to use a renderer to output the results of your components. Every React app uses some renderer:
11
+
12
+ - React Native is a renderer for mobile apps,
13
+ - React DOM is a renderer for web apps,
14
+ - There are other more [specialized renderers](https://github.com/chentsulin/awesome-react-renderer) that can e.g., render to console or HTML canvas.
15
+
16
+ When you run your tests in the React Native Testing Library, somewhat contrary to what the name suggests, they are actually **not** using React Native renderer. This is because this renderer needs to be run on an iOS or Android operating system, so it would need to run on a device or simulator.
17
+
18
+ ## Test Renderer
19
+
20
+ Instead, RNTL uses [Test Renderer](https://github.com/mdjastrzebski/test-renderer), a modern, actively maintained renderer that renders to pure JavaScript objects without access to mobile OS and runs in a Node.js environment using Jest (or any other JavaScript test runner). Test Renderer replaces the deprecated `react-test-renderer` package and has better compatibility with React 19 and improved type safety.
21
+
22
+ Using Test Renderer has trade-offs:
23
+
24
+ Benefits:
25
+
26
+ - Tests run on most CIs (Linux, etc) without a mobile device or emulator
27
+ - Faster test execution
28
+ - Light runtime environment
29
+
30
+ Limitations:
31
+
32
+ - Tests don't execute native code
33
+ - Tests are unaware of view state managed by native components, e.g., focus, unmanaged text boxes, etc.
34
+ - Assertions don't operate on native view hierarchy
35
+ - Runtime behaviors are simulated, sometimes imperfectly
36
+
37
+ It's worth noting that the React Testing Library (web one) works a bit differently. While RTL also runs in Jest, it has access to a simulated browser DOM environment from the `jsdom` package, which allows it to use a regular React DOM renderer. Unfortunately, there is no similar React Native runtime environment package. This is probably because while the browser environment is well-defined and highly standardized, the React Native environment constantly evolves in sync with the evolution of underlying OS-es. Maintaining such an environment would require duplicating countless React Native behaviors and keeping them in sync as React Native develops.
38
+
39
+ ## Element tree
40
+
41
+ Calling the `render()` function creates an element tree. This is done internally by invoking the `createRoot()` function from Test Renderer. The output tree represents your React Native component tree, containing only host elements. Each node of that tree corresponds to a host component that would have a counterpart in the native view hierarchy.
42
+
43
+ These tree elements are represented by `TestInstance` type from Test Renderer:
44
+
45
+ ```tsx
46
+ interface TestInstance {
47
+ type: ElementType;
48
+ props: { [propName: string]: any };
49
+ parent: TestInstance | null;
50
+ children: Array<TestInstance | string>;
51
+
52
+ // Other props and methods
53
+ }
54
+ ```
55
+
56
+ For more details, see the [Test Renderer documentation](https://github.com/mdjastrzebski/test-renderer).
57
+
58
+ ## Host and composite components
59
+
60
+ To understand RNTL's element tree, it's important to know the difference between host and composite components in React Native:
61
+
62
+ - [Host components](https://reactnative.dev/architecture/glossary#react-host-components-or-host-components) have direct counterparts in the native view tree. Typical examples are `<View>`, `<Text>`, `<TextInput>`, and `<Image>` from React Native. You can think of these as an analog of `<div>`, `<span>` etc on the Web. You can also create custom host views as native modules or import them from 3rd party libraries, like React Navigation or React Native Gesture Handler.
63
+ - [Composite components](https://reactnative.dev/architecture/glossary#react-composite-components) are React code organization units that exist only on the JavaScript side of your app. Typical examples are components you create (function and class components), components imported from React Native (`View`, `Text`, etc.), or 3rd party packages.
64
+
65
+ That might initially sound confusing since we put React Native's `View` in both categories. There are two `View` components: composite and host. The relation between them is as follows:
66
+
67
+ - Composite `View` is the type imported from the `react-native` package. It is a JavaScript component that renders the host `View` as its only child.
68
+ - Host `View`, which you do not render directly. React Native takes the props you pass to the composite `View`, does some processing on them and passes them to the host `View`.
69
+
70
+ In a full React tree, this would look like:
71
+
72
+ ```jsx
73
+ * <View> (composite)
74
+ * <View> (host)
75
+ * children prop passed in JSX
76
+ ```
77
+
78
+ A similar relation exists between other composite and host pairs: e.g. `Text`, `TextInput`, and `Image` components.
79
+
80
+ Not all React Native components are organized this way, e.g., when you use `Pressable` (or `TouchableOpacity`), there is no host `Pressable`, but composite `Pressable` is rendering a host `View` with specific props being set:
81
+
82
+ ```jsx
83
+ * <Pressable> (composite)
84
+ * <View accessible={true} {...}> (host)
85
+ * children prop passed in JSX
86
+ ```
87
+
88
+ ### Host-only element tree
89
+
90
+ In RNTL v14, [Test Renderer](https://github.com/mdjastrzebski/test-renderer) only exposes host elements in the element tree. Composite components aren't visible in the tree—you only see their host element output. This aligns with Testing Library's philosophy: tests should focus on what users can see and interact with (host elements), not implementation details (composite components).
91
+
92
+ For a `TestInstance`, the `type` prop is always a string value representing the host component name, e.g., `"View"`, `"Text"`, `"TextInput"`.
93
+
94
+ ## Tree nodes
95
+
96
+ RNTL v14 queries and the element tree only expose host elements. Tests assert on what users can see and interact with. Host elements represent the actual UI controls users interact with, while composite components exist purely in the JavaScript domain.
97
+
98
+ ### Understanding props
99
+
100
+ When asserting props on host elements, you're verifying what actually reaches the native view. This is important because composite components may process, transform, or even forget to pass props to their host children.
101
+
102
+ ```jsx
103
+ function ForgotToPassPropsButton({ title, onPress, style }) {
104
+ return (
105
+ <Pressable>
106
+ <Text>{title}</Text>
107
+ </Pressable>
108
+ );
109
+ }
110
+ ```
111
+
112
+ In the above example, the component accepts `onPress` and `style` props but doesn't pass them to host views, so they won't affect the user interface. By testing host elements, RNTL helps you catch these issues: if a prop doesn't reach a host element, users won't see or interact with it.
113
+
114
+ ## Tree navigation
115
+
116
+ > [!CAUTION]
117
+ > You should avoid navigating over the element tree, as this makes your testing code fragile and may result in false positives. This section is more relevant for people who want to contribute to our codebase.
118
+
119
+ You can navigate the tree of host elements using `parent` or `children` props of a `TestInstance`. Be careful when doing this, as the tree structure for third-party components can change independently from your code and cause unexpected test failures.
120
+
121
+ ## Queries
122
+
123
+ All Testing Library queries return host components to encourage the best practices described above. Since v14, RNTL uses [Test Renderer](https://github.com/mdjastrzebski/test-renderer), which only renders host elements, making it impossible to query composite components directly.
@@ -0,0 +1,61 @@
1
+ # Troubleshooting
2
+
3
+ This guide describes common issues found by users when integrating React Native Test Library to their projects:
4
+
5
+ ## Example repository
6
+
7
+ We maintain an [example repository](https://github.com/callstack/react-native-testing-library/tree/main/examples/basic) with a React Native Testing Library setup using TypeScript.
8
+
9
+ If something doesn't work in your setup, check this repository for configuration examples.
10
+
11
+ ## Undefined component error
12
+
13
+ > Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
14
+
15
+ This frequently happens when you mock a complex module incorrectly, e.g.:
16
+
17
+ ```ts
18
+ jest.mock('@react-navigation/native', () => {
19
+ return {
20
+ useNavigation: jest.fn(),
21
+ };
22
+ });
23
+ ```
24
+
25
+ The above mock will mock `useNavigation` hook as intended, but at the same time all other exports from `@react-navigation/native` package are now `undefined`. If you want to use `NavigationContainer` component from the same package it will be `undefined` and result in the error above.
26
+
27
+ To mock only part of a package, re-export all other exports using `jest.requireActual`:
28
+
29
+ ```ts
30
+ jest.mock('@react-navigation/native', () => {
31
+ return {
32
+ ...jest.requireActual('@react-navigation/native'),
33
+ useNavigation: jest.fn(),
34
+ };
35
+ });
36
+ ```
37
+
38
+ That way the mock will re-export all of the `@react-navigation/native` members and overwrite only the `useNavigation` hook.
39
+
40
+ Alternatively, you can use `jest.spyOn` to mock package exports selectively.
41
+
42
+ ### Mocking React Native
43
+
44
+ When mocking the `react-native` package, don't mock the whole package at once, as this has issues with `jest.requireActual`. Mock specific library paths inside the package instead, e.g.:
45
+
46
+ ```ts title=jest-setup.ts
47
+ jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
48
+ ```
49
+
50
+ ## Act warnings
51
+
52
+ When writing tests you may encounter warnings connected with `act()` function. There are two kinds of these warnings:
53
+
54
+ - sync `act()` warning - `Warning: An update to Component inside a test was not wrapped in act(...)`
55
+ - async `act()` warning - `Warning: You called act(async () => ...) without await`
56
+
57
+ You can read more about `act()` function in our [understanding `act` function guide](./understanding-act.md).
58
+
59
+ Normally, you should not encounter sync `act()` warnings, but if that happens this probably indicate an issue with your test and should be investigated.
60
+
61
+ In case of async `act()` function this might happen more or less randomly, especially if your components contain async logic. So far this warning does not seem to affect test correctness.
@@ -0,0 +1,207 @@
1
+ # Understanding `act` function
2
+
3
+ When writing RNTL tests, cryptic [`act()`](https://react.dev/link/wrap-tests-with-act) function errors logged to console often confuse developers. This article explains the purpose and behavior of `act()` so you can write tests with more confidence.
4
+
5
+ ## `act` warning
6
+
7
+ Let's start with a typical `act()` warning logged to console:
8
+
9
+ ```
10
+ An update to Root inside a test was not wrapped in act(...).
11
+
12
+ When testing, code that causes React state updates should be wrapped into act(...):
13
+
14
+ act(() => {
15
+ /* fire events that update state */
16
+ });
17
+ /* assert on the output */
18
+
19
+ This ensures that you're testing the behavior the user would see in the browser.
20
+ Learn more at https://react.dev/link/wrap-tests-with-act
21
+ ```
22
+
23
+ ## Understanding `act`
24
+
25
+ ### Responsibility
26
+
27
+ This function is intended only for using in automated tests and works only in development mode. Attempting to use it in production build will throw an error.
28
+
29
+ The responsibility for `act` function is to make React renders and updates work in tests in a similar way they work in real application by grouping and executing related units of interaction (e.g. renders, effects, etc) together.
30
+
31
+ Let's demonstrate this with a small experiment. First, define a function component that uses `useEffect`:
32
+
33
+ ```jsx
34
+ function TestComponent() {
35
+ const [count, setCount] = React.useState(0);
36
+ React.useEffect(() => {
37
+ setCount((c) => c + 1);
38
+ }, []);
39
+
40
+ return <Text>Count {count}</Text>;
41
+ }
42
+ ```
43
+
44
+ In the following tests we will directly use [Test Renderer](https://github.com/mdjastrzebski/test-renderer) instead of RNTL `render` function to render our component for tests. In order to expose familiar queries like `getByText` we will use `within` function from RNTL.
45
+
46
+ ```jsx
47
+ import { createRoot } from 'test-renderer';
48
+ import { within } from '@testing-library/react-native';
49
+
50
+ test('render without act', () => {
51
+ const renderer = createRoot();
52
+ renderer.render(<TestComponent />);
53
+
54
+ // Bind RNTL queries for root element.
55
+ const view = within(renderer.container);
56
+ expect(view.getByText('Count 0')).toBeTruthy();
57
+ });
58
+ ```
59
+
60
+ When testing without `act` wrapping the render call, the assertion runs just after rendering but before `useEffect` effects are applied. This isn't what we expected.
61
+
62
+ ```jsx
63
+ import { createRoot } from 'test-renderer';
64
+ import { act, within } from '@testing-library/react-native';
65
+
66
+ test('render with act', async () => {
67
+ const renderer = createRoot();
68
+ await act(() => {
69
+ renderer.render(<TestComponent />);
70
+ });
71
+
72
+ // Bind RNTL queries for root element.
73
+ const view = within(renderer.container);
74
+ expect(view.getByText('Count 1')).toBeTruthy();
75
+ });
76
+ ```
77
+
78
+ **Note**: In v14, `act` is now async by default and always returns a Promise. You should always use `await act(...)`.
79
+
80
+ When wrapping rendering call with `act` we see that the changes caused by `useEffect` hook have been applied as we would expect.
81
+
82
+ ### When to use act
83
+
84
+ The name `act` comes from [Arrange-Act-Assert](http://wiki.c2.com/?ArrangeActAssert) unit testing pattern. Which means it's related to part of the test when we execute some actions on the component tree.
85
+
86
+ So far we learned that `act` function allows tests to wait for all pending React interactions to be applied before we make our assertions. When using `act` we get guarantee that any state updates will be executed as well as any enqueued effects will be executed.
87
+
88
+ Therefore, we should use `act` whenever there is some action that causes element tree to render, particularly:
89
+
90
+ - initial render call - `renderer.render` call
91
+ - re-rendering of component - `renderer.render` call with updated element
92
+ - triggering any event handlers that cause component tree render
93
+
94
+ Thankfully, for these basic cases RNTL has got you covered as our `render`, `rerender` and `fireEvent` methods already wrap their calls in `act` so that you do not have to do it explicitly. In v14, these functions are all async and should be awaited.
95
+
96
+ Note that `act` calls can be safely nested and internally form a stack of calls.
97
+
98
+ ### Implementation
99
+
100
+ The `act` implementation is defined in the [ReactAct.js source file](https://github.com/facebook/react/blob/main/packages/react/src/ReactAct.js) inside React repository. RNTL v14 requires React 19+, which provides the `act` function directly via `React.act`.
101
+
102
+ RNTL exports `act` for convenience as defined in the [act.ts source file](https://github.com/callstack/react-native-testing-library/blob/main/src/act.ts). In v14, `act` is async by default and always returns a Promise. This works with async React features like `Suspense` boundaries and the `use()` hook. The underlying implementation wraps React's `act` function to ensure consistent async behavior.
103
+
104
+ **Important**: You should always use `act` exported from `@testing-library/react-native` rather than the one from `react`. The RNTL version automatically ensures async behavior, whereas using `React.act` directly could still trigger synchronous act behavior if used improperly, leading to subtle test issues.
105
+
106
+ ## Asynchronous code
107
+
108
+ In v14, `act` is always async and returns a Promise. While the callback you pass to `act` can be synchronous (dealing with things like synchronous effects or mocks using already resolved promises), the `act` function itself should always be awaited. However, not all component code is synchronous. Frequently our components or mocks contain some asynchronous behaviours like `setTimeout` calls or network calls.
109
+
110
+ ### Handling asynchronous operations
111
+
112
+ When the callback passed to `act` contains asynchronous operations, the Promise returned by `act` will resolve only after those operations complete.
113
+
114
+ Here's a simple example with a component using `setTimeout` to simulate asynchronous behavior:
115
+
116
+ ```jsx
117
+ function TestAsyncComponent() {
118
+ const [count, setCount] = React.useState(0);
119
+ React.useEffect(() => {
120
+ setTimeout(() => {
121
+ setCount((c) => c + 1);
122
+ }, 50);
123
+ }, []);
124
+
125
+ return <Text>Count {count}</Text>;
126
+ }
127
+ ```
128
+
129
+ ```jsx
130
+ import { render, screen } from '@testing-library/react-native';
131
+
132
+ test('render async natively', async () => {
133
+ await render(<TestAsyncComponent />);
134
+ expect(screen.getByText('Count 0')).toBeOnTheScreen();
135
+ });
136
+ ```
137
+
138
+ If we test our component in a native way without handling its asynchronous behaviour we will end up with an act warning. This is because the `setTimeout` callback will trigger a state update after the test has finished.
139
+
140
+ ### Solution with fake timers
141
+
142
+ Use Jest's fake timers:
143
+
144
+ ```jsx
145
+ test('render with fake timers', async () => {
146
+ jest.useFakeTimers();
147
+ await render(<TestAsyncComponent />);
148
+
149
+ await act(() => {
150
+ jest.runAllTimers();
151
+ });
152
+ expect(screen.getByText('Count 1')).toBeOnTheScreen();
153
+ });
154
+ ```
155
+
156
+ **Note**: In v14, both `render` and `act` are async by default, so you should await them.
157
+
158
+ That way we can wrap `jest.runAllTimers()` call which triggers the `setTimeout` updates inside an `act` call, hence resolving the act warning.
159
+
160
+ ### Solution with real timers
161
+
162
+ With real timers, things get more complex. Start with a simple solution: wrap an async `act()` call for the expected duration of component updates:
163
+
164
+ ```jsx
165
+ test('render with real timers - sleep', async () => {
166
+ await render(<TestAsyncComponent />);
167
+ await act(() => {
168
+ await sleep(100); // Wait a bit longer than setTimeout in `TestAsyncComponent`
169
+ });
170
+
171
+ expect(screen.getByText('Count 1')).toBeOnTheScreen();
172
+ });
173
+ ```
174
+
175
+ This works correctly as we use an explicit async `act()` call that resolves the console error. However, it relies on our knowledge of exact implementation details which is a bad practice.
176
+
177
+ A better solution uses `waitFor` to wait for the desired state:
178
+
179
+ ```jsx
180
+ test('render with real timers - waitFor', async () => {
181
+ await render(<TestAsyncComponent />);
182
+
183
+ await waitFor(() => screen.getByText('Count 1'));
184
+ expect(screen.getByText('Count 1')).toBeOnTheScreen();
185
+ });
186
+ ```
187
+
188
+ This also works correctly, because `waitFor` call executes async `act()` call internally.
189
+
190
+ The above code can be simplified using `findBy` query:
191
+
192
+ ```jsx
193
+ test('render with real timers - findBy', async () => {
194
+ await render(<TestAsyncComponent />);
195
+
196
+ expect(await screen.findByText('Count 1')).toBeOnTheScreen();
197
+ });
198
+ ```
199
+
200
+ This also works since `findByText` internally calls `waitFor` which uses async `act()`.
201
+
202
+ Note that all of the above examples are async tests using & awaiting async `act()` function call.
203
+
204
+ ## References
205
+
206
+ - [React `act` implementation source](https://github.com/facebook/react/blob/main/packages/react/src/ReactAct.js)
207
+ - [React testing documentation](https://react.dev/link/wrap-tests-with-act)
package/matchers.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './build/matchers';
1
+ export * from './dist/matchers';
package/matchers.js CHANGED
@@ -1,2 +1,2 @@
1
- // makes it so people can import from '@testing-library/react-native/pure'
2
- module.exports = require('./build/matchers');
1
+ // makes it so people can import from '@testing-library/react-native/matchers'
2
+ module.exports = require('./dist/matchers');
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "14.0.0-rc.0",
3
+ "version": "14.0.0-rc.2",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
- "main": "build/index.js",
6
- "types": "build/index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://www.github.com/callstack/react-native-testing-library.git"
@@ -23,11 +23,13 @@
23
23
  "integration"
24
24
  ],
25
25
  "scripts": {
26
- "clean": "del build",
26
+ "clean": "del dist",
27
27
  "test": "jest",
28
28
  "test:ci": "jest --maxWorkers=2",
29
29
  "test:ci:coverage": "jest --maxWorkers=2 --collectCoverage=true",
30
30
  "test:codemods": "node scripts/test-codemods.mjs",
31
+ "docs:generate": "node scripts/generate-package-docs.mjs",
32
+ "docs:check": "yarn docs:generate && git diff --exit-code -- docs",
31
33
  "typecheck": "tsc",
32
34
  "typecheck:react-19_2": "tsc -p tsconfig.react-19_2.json",
33
35
  "lint": "eslint src --cache",
@@ -35,23 +37,23 @@
35
37
  "prettier:fix": "prettier --write .",
36
38
  "validate": "yarn typecheck && yarn test && yarn lint && yarn prettier",
37
39
  "validate:examples": "yarn --cwd examples/basic validate && yarn --cwd examples/cookbook validate",
38
- "validate:all": "yarn validate && yarn validate:examples && yarn --cwd website validate && yarn --cwd experiments-app validate",
39
- "validate:fix": "yarn prettier:fix && yarn lint --fix && yarn typecheck && yarn test -u",
40
- "build:js": "babel src --out-dir build --extensions \".js,.ts,.jsx,.tsx\" --source-maps --ignore \"**/__tests__/**\"",
40
+ "validate:all": "yarn validate && yarn validate:examples && yarn docs:check && yarn --cwd website validate && yarn --cwd experiments-app validate",
41
+ "validate:fix": "yarn prettier:fix && yarn lint --fix && yarn typecheck && yarn test -u && docs:generate",
42
+ "build:js": "babel src --out-dir dist --extensions \".js,.ts,.jsx,.tsx\" --source-maps --ignore \"**/__tests__/**\"",
41
43
  "build:ts": "tsc --build tsconfig.release.json",
42
44
  "build": "yarn clean && yarn build:js && yarn build:ts",
43
45
  "release": "release-it",
44
- "release:rc": "release-it --preRelease=rc",
45
- "release:beta": "release-it --preRelease=beta",
46
- "release:codemods": "release-it --preRelease=alpha"
46
+ "release:next": "release-it --preRelease=rc --npm.tag=next",
47
+ "release:codemods": "yarn test:codemods && yarn dlx codemod@latest publish codemods/v14-async-functions && yarn dlx codemod@latest publish codemods/v14-update-deps"
47
48
  },
48
49
  "files": [
49
- "build/",
50
+ "dist/",
50
51
  "matchers.js",
51
52
  "matchers.d.ts",
52
53
  "pure.js",
53
54
  "pure.d.ts",
54
- "dont-cleanup-after-each.js"
55
+ "dont-cleanup-after-each.js",
56
+ "docs/"
55
57
  ],
56
58
  "dependencies": {
57
59
  "jest-matcher-utils": "^30.3.0",
package/pure.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './build/pure';
1
+ export * from './dist/pure';
package/pure.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // makes it so people can import from '@testing-library/react-native/pure'
2
- module.exports = require('./build/pure');
2
+ module.exports = require('./dist/pure');
@@ -1 +0,0 @@
1
- {"version":3,"file":"accessibility.js","names":["_reactNative","require","_componentTree","_findAll","_hostComponentNames","_textContent","_textInput","accessibilityStateKeys","exports","accessibilityValueKeys","isHiddenFromAccessibility","instance","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getInstanceSiblings","some","sibling","computeAriaModal","isAccessibilityElement","isHostImage","alt","accessible","isHostText","isHostTextInput","isHostSwitch","getRole","explicitRole","role","accessibilityRole","normalizeRole","accessibilityViewIsModal","computeAriaLabel","labelElementId","accessibilityLabelledBy","container","getContainerInstance","labelInstance","findAll","node","isTestInstance","nativeID","includeHiddenElements","length","getTextContent","explicitLabel","accessibilityLabel","computeAriaBusy","accessibilityState","busy","computeAriaChecked","value","rolesSupportingCheckedState","checked","computeAriaDisabled","isEditableTextInput","disabled","computeAriaExpanded","expanded","computeAriaSelected","selected","computeAriaValue","accessibilityValue","ariaValueMax","ariaValueMin","ariaValueNow","ariaValueText","max","min","now","text","computeAccessibleName","options","label","placeholder","root","parts","child","children","push","childLabel","join","checkbox","radio","switch"],"sources":["../../src/helpers/accessibility.ts"],"sourcesContent":["import type { AccessibilityRole, AccessibilityState, AccessibilityValue, Role } from 'react-native';\nimport { StyleSheet } from 'react-native';\nimport type { TestInstance } from 'test-renderer';\n\nimport { getContainerInstance, getInstanceSiblings, isTestInstance } from './component-tree';\nimport { findAll } from './find-all';\nimport { isHostImage, isHostSwitch, isHostText, isHostTextInput } from './host-component-names';\nimport { getTextContent } from './text-content';\nimport { isEditableTextInput } from './text-input';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<TestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessibilityValueKeys: (keyof AccessibilityValue)[] = ['min', 'max', 'now', 'text'];\n\nexport function isHiddenFromAccessibility(\n instance: TestInstance | null,\n { cache }: IsInaccessibleOptions = {},\n): boolean {\n if (instance == null) {\n return true;\n }\n\n let current: TestInstance | null = instance;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(instance: TestInstance): boolean {\n // See: https://reactnative.dev/docs/accessibility#aria-hidden\n if (instance.props['aria-hidden']) {\n return true;\n }\n\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (instance.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (instance.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not treated as inaccessible on iOS\n const flatStyle = StyleSheet.flatten(instance.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal or aria-modal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getInstanceSiblings(instance);\n if (hostSiblings.some((sibling) => computeAriaModal(sibling))) {\n return true;\n }\n\n return false;\n}\n\nexport function isAccessibilityElement(instance: TestInstance | null): boolean {\n if (instance == null) {\n return false;\n }\n\n // https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L172\n if (isHostImage(instance) && instance.props.alt !== undefined) {\n return true;\n }\n\n if (instance.props.accessible !== undefined) {\n return instance.props.accessible;\n }\n\n return isHostText(instance) || isHostTextInput(instance) || isHostSwitch(instance);\n}\n\n/**\n * Returns the accessibility role for given element. It will return explicit\n * role from either `role` or `accessibilityRole` props if set.\n *\n * If explicit role is not available, it would try to return default element\n * role:\n * - `text` for `Text` elements\n *\n * In all other cases this functions returns `none`.\n *\n * @param instance\n * @returns\n */\nexport function getRole(instance: TestInstance): Role | AccessibilityRole {\n const explicitRole = instance.props.role ?? instance.props.accessibilityRole;\n if (explicitRole) {\n return normalizeRole(explicitRole);\n }\n\n if (isHostText(instance)) {\n return 'text';\n }\n\n // Note: host Image elements report \"image\" role in screen reader only on Android, but not on iOS.\n // It's better to require explicit role for Image elements.\n\n return 'none';\n}\n\n/**\n * There are some duplications between (ARIA) `Role` and `AccessibilityRole` types.\n * Resolve them by using ARIA `Role` type where possible.\n *\n * @param role Role to normalize\n * @returns Normalized role\n */\nexport function normalizeRole(role: string): Role | AccessibilityRole {\n if (role === 'image') {\n return 'img';\n }\n\n return role as Role | AccessibilityRole;\n}\n\nexport function computeAriaModal(instance: TestInstance): boolean | undefined {\n return instance.props['aria-modal'] ?? instance.props.accessibilityViewIsModal;\n}\n\nexport function computeAriaLabel(instance: TestInstance): string | undefined {\n const labelElementId =\n instance.props['aria-labelledby'] ?? instance.props.accessibilityLabelledBy;\n if (labelElementId) {\n const container = getContainerInstance(instance);\n const labelInstance = findAll(\n container,\n (node) => isTestInstance(node) && node.props.nativeID === labelElementId,\n { includeHiddenElements: true },\n );\n if (labelInstance.length > 0) {\n return getTextContent(labelInstance[0]);\n }\n }\n\n const explicitLabel = instance.props['aria-label'] ?? instance.props.accessibilityLabel;\n if (explicitLabel) {\n return explicitLabel;\n }\n\n //https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L173\n if (isHostImage(instance) && instance.props.alt) {\n return instance.props.alt;\n }\n\n return undefined;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#busy-state\nexport function computeAriaBusy({ props }: TestInstance): boolean {\n return props['aria-busy'] ?? props.accessibilityState?.busy ?? false;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#checked-state\nexport function computeAriaChecked(instance: TestInstance): AccessibilityState['checked'] {\n const { props } = instance;\n\n if (isHostSwitch(instance)) {\n return props.value;\n }\n\n const role = getRole(instance);\n if (!rolesSupportingCheckedState[role]) {\n return undefined;\n }\n\n return props['aria-checked'] ?? props.accessibilityState?.checked;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#disabled-state\nexport function computeAriaDisabled(instance: TestInstance): boolean {\n if (isHostTextInput(instance) && !isEditableTextInput(instance)) {\n return true;\n }\n\n const { props } = instance;\n\n if (isHostText(instance) && props.disabled) {\n return true;\n }\n\n return props['aria-disabled'] ?? props.accessibilityState?.disabled ?? false;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#expanded-state\nexport function computeAriaExpanded({ props }: TestInstance): boolean | undefined {\n return props['aria-expanded'] ?? props.accessibilityState?.expanded;\n}\n\n// See: https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State#selected-state\nexport function computeAriaSelected({ props }: TestInstance): boolean {\n return props['aria-selected'] ?? props.accessibilityState?.selected ?? false;\n}\n\nexport function computeAriaValue(instance: TestInstance): AccessibilityValue {\n const {\n accessibilityValue,\n 'aria-valuemax': ariaValueMax,\n 'aria-valuemin': ariaValueMin,\n 'aria-valuenow': ariaValueNow,\n 'aria-valuetext': ariaValueText,\n } = instance.props;\n\n return {\n max: ariaValueMax ?? accessibilityValue?.max,\n min: ariaValueMin ?? accessibilityValue?.min,\n now: ariaValueNow ?? accessibilityValue?.now,\n text: ariaValueText ?? accessibilityValue?.text,\n };\n}\n\ntype ComputeAccessibleNameOptions = {\n root?: boolean;\n};\n\nexport function computeAccessibleName(\n instance: TestInstance,\n options?: ComputeAccessibleNameOptions,\n): string | undefined {\n const label = computeAriaLabel(instance);\n if (label) {\n return label;\n }\n\n if (isHostTextInput(instance) && instance.props.placeholder && options?.root !== false) {\n return instance.props.placeholder;\n }\n\n const parts = [];\n for (const child of instance.children) {\n if (typeof child === 'string') {\n if (child) {\n parts.push(child);\n }\n } else {\n const childLabel = computeAccessibleName(child, { root: false });\n if (childLabel) {\n parts.push(childLabel);\n }\n }\n }\n\n return parts.join(' ');\n}\n\ntype RoleSupportMap = Partial<Record<Role | AccessibilityRole, true>>;\n\nexport const rolesSupportingCheckedState: RoleSupportMap = {\n checkbox: true,\n radio: true,\n switch: true,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAMO,MAAMM,sBAAoD,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAEM,MAAME,sBAAoD,GAAAD,OAAA,CAAAC,sBAAA,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;AAE1F,SAASC,yBAAyBA,CACvCC,QAA6B,EAC7B;EAAEC;AAA6B,CAAC,GAAG,CAAC,CAAC,EAC5B;EACT,IAAID,QAAQ,IAAI,IAAI,EAAE;IACpB,OAAO,IAAI;EACb;EAEA,IAAIE,OAA4B,GAAGF,QAAQ;EAC3C,OAAOE,OAAO,EAAE;IACd,IAAIC,4BAA4B,GAAGF,KAAK,EAAEG,GAAG,CAACF,OAAO,CAAC;IAEtD,IAAIC,4BAA4B,KAAKE,SAAS,EAAE;MAC9CF,4BAA4B,GAAGG,qBAAqB,CAACJ,OAAO,CAAC;MAC7DD,KAAK,EAAEM,GAAG,CAACL,OAAO,EAAEC,4BAA4B,CAAC;IACnD;IAEA,IAAIA,4BAA4B,EAAE;MAChC,OAAO,IAAI;IACb;IAEAD,OAAO,GAAGA,OAAO,CAACM,MAAM;EAC1B;EAEA,OAAO,KAAK;AACd;;AAEA;AACO,MAAMC,c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,KAAK,KAAK,EAAE;IACtF,OAAO/E,QAAQ,CAACU,KAAK,CAACoE,WAAW;EACnC;EAEA,MAAME,KAAK,GAAG,EAAE;EAChB,KAAK,MAAMC,KAAK,IAAIjF,QAAQ,CAACkF,QAAQ,EAAE;IACrC,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC7B,IAAIA,KAAK,EAAE;QACTD,KAAK,CAACG,IAAI,CAACF,KAAK,CAAC;MACnB;IACF,CAAC,MAAM;MACL,MAAMG,UAAU,GAAGT,qBAAqB,CAACM,KAAK,EAAE;QAAEF,IAAI,EAAE;MAAM,CAAC,CAAC;MAChE,IAAIK,UAAU,EAAE;QACdJ,KAAK,CAACG,IAAI,CAACC,UAAU,CAAC;MACxB;IACF;EACF;EAEA,OAAOJ,KAAK,CAACK,IAAI,CAAC,GAAG,CAAC;AACxB;AAIO,MAAM7B,2BAA2C,GAAA3D,OAAA,CAAA2D,2BAAA,GAAG;EACzD8B,QAAQ,EAAE,IAAI;EACdC,KAAK,EAAE,IAAI;EACXC,MAAM,EAAE;AACV,CAAC","ignoreList":[]}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes