@testing-library/react-native 13.0.0-rc.0 → 13.0.1

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 (187) hide show
  1. package/README.md +1 -1
  2. package/build/act.d.ts +1 -1
  3. package/build/act.js +1 -3
  4. package/build/act.js.map +1 -1
  5. package/build/config.d.ts +1 -1
  6. package/build/config.js.map +1 -1
  7. package/build/fire-event.d.ts +3 -3
  8. package/build/fire-event.js.map +1 -1
  9. package/build/helpers/accessibility.d.ts +1 -1
  10. package/build/helpers/accessibility.js.map +1 -1
  11. package/build/helpers/component-tree.d.ts +1 -1
  12. package/build/helpers/component-tree.js.map +1 -1
  13. package/build/helpers/debug.d.ts +3 -3
  14. package/build/helpers/debug.js +8 -11
  15. package/build/helpers/debug.js.map +1 -1
  16. package/build/helpers/errors.js +4 -4
  17. package/build/helpers/errors.js.map +1 -1
  18. package/build/helpers/find-all.d.ts +2 -2
  19. package/build/helpers/find-all.js.map +1 -1
  20. package/build/helpers/format-element.d.ts +18 -0
  21. package/build/helpers/format-element.js +81 -0
  22. package/build/helpers/format-element.js.map +1 -0
  23. package/build/helpers/host-component-names.d.ts +2 -2
  24. package/build/helpers/host-component-names.js.map +1 -1
  25. package/build/helpers/logger.d.ts +6 -0
  26. package/build/helpers/logger.js +37 -0
  27. package/build/helpers/logger.js.map +1 -0
  28. package/build/helpers/{format-default.d.ts → map-props.d.ts} +1 -0
  29. package/build/helpers/{format-default.js → map-props.js} +2 -2
  30. package/build/helpers/map-props.js.map +1 -0
  31. package/build/helpers/matchers/match-accessibility-state.d.ts +1 -1
  32. package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
  33. package/build/helpers/matchers/match-accessibility-value.d.ts +2 -2
  34. package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
  35. package/build/helpers/matchers/match-label-text.d.ts +2 -2
  36. package/build/helpers/matchers/match-label-text.js.map +1 -1
  37. package/build/helpers/matchers/match-string-prop.d.ts +1 -1
  38. package/build/helpers/matchers/match-string-prop.js.map +1 -1
  39. package/build/helpers/matchers/match-text-content.d.ts +1 -1
  40. package/build/helpers/matchers/match-text-content.js.map +1 -1
  41. package/build/helpers/object.d.ts +1 -1
  42. package/build/helpers/object.js.map +1 -1
  43. package/build/helpers/pointer-events.d.ts +1 -1
  44. package/build/helpers/pointer-events.js.map +1 -1
  45. package/build/helpers/string-validation.d.ts +1 -1
  46. package/build/helpers/string-validation.js.map +1 -1
  47. package/build/helpers/text-input.d.ts +1 -1
  48. package/build/helpers/text-input.js.map +1 -1
  49. package/build/helpers/timers.d.ts +1 -1
  50. package/build/helpers/timers.js.map +1 -1
  51. package/build/index.flow.js +28 -32
  52. package/build/index.js +3 -4
  53. package/build/index.js.map +1 -1
  54. package/build/matchers/extend-expect.js +2 -2
  55. package/build/matchers/extend-expect.js.map +1 -1
  56. package/build/matchers/index.d.ts +1 -1
  57. package/build/matchers/index.js.map +1 -1
  58. package/build/matchers/to-be-busy.d.ts +1 -1
  59. package/build/matchers/to-be-busy.js +4 -1
  60. package/build/matchers/to-be-busy.js.map +1 -1
  61. package/build/matchers/to-be-checked.js +4 -1
  62. package/build/matchers/to-be-checked.js.map +1 -1
  63. package/build/matchers/to-be-disabled.js +5 -2
  64. package/build/matchers/to-be-disabled.js.map +1 -1
  65. package/build/matchers/to-be-empty-element.d.ts +1 -1
  66. package/build/matchers/to-be-empty-element.js +4 -1
  67. package/build/matchers/to-be-empty-element.js.map +1 -1
  68. package/build/matchers/to-be-expanded.d.ts +1 -1
  69. package/build/matchers/to-be-expanded.js +5 -2
  70. package/build/matchers/to-be-expanded.js.map +1 -1
  71. package/build/matchers/to-be-on-the-screen.js +4 -1
  72. package/build/matchers/to-be-on-the-screen.js.map +1 -1
  73. package/build/matchers/to-be-partially-checked.js +4 -1
  74. package/build/matchers/to-be-partially-checked.js.map +1 -1
  75. package/build/matchers/to-be-selected.d.ts +1 -1
  76. package/build/matchers/to-be-selected.js +4 -1
  77. package/build/matchers/to-be-selected.js.map +1 -1
  78. package/build/matchers/to-be-visible.js +5 -2
  79. package/build/matchers/to-be-visible.js.map +1 -1
  80. package/build/matchers/to-contain-element.d.ts +1 -1
  81. package/build/matchers/to-contain-element.js +4 -1
  82. package/build/matchers/to-contain-element.js.map +1 -1
  83. package/build/matchers/to-have-accessibility-value.d.ts +1 -1
  84. package/build/matchers/to-have-accessibility-value.js.map +1 -1
  85. package/build/matchers/to-have-accessible-name.d.ts +1 -1
  86. package/build/matchers/to-have-accessible-name.js.map +1 -1
  87. package/build/matchers/to-have-display-value.d.ts +1 -1
  88. package/build/matchers/to-have-display-value.js +1 -1
  89. package/build/matchers/to-have-display-value.js.map +1 -1
  90. package/build/matchers/to-have-prop.js.map +1 -1
  91. package/build/matchers/to-have-style.d.ts +1 -1
  92. package/build/matchers/to-have-style.js.map +1 -1
  93. package/build/matchers/to-have-text-content.d.ts +1 -1
  94. package/build/matchers/to-have-text-content.js.map +1 -1
  95. package/build/matchers/types.d.ts +3 -3
  96. package/build/matchers/types.js.map +1 -1
  97. package/build/matchers/utils.d.ts +1 -8
  98. package/build/matchers/utils.js +0 -41
  99. package/build/matchers/utils.js.map +1 -1
  100. package/build/native-state.d.ts +3 -3
  101. package/build/native-state.js +1 -1
  102. package/build/native-state.js.map +1 -1
  103. package/build/queries/display-value.d.ts +1 -1
  104. package/build/queries/display-value.js.map +1 -1
  105. package/build/queries/hint-text.d.ts +2 -2
  106. package/build/queries/hint-text.js.map +1 -1
  107. package/build/queries/label-text.d.ts +2 -2
  108. package/build/queries/label-text.js.map +1 -1
  109. package/build/queries/make-queries.js +5 -8
  110. package/build/queries/make-queries.js.map +1 -1
  111. package/build/queries/options.d.ts +1 -1
  112. package/build/queries/options.js.map +1 -1
  113. package/build/queries/placeholder-text.d.ts +1 -1
  114. package/build/queries/placeholder-text.js +1 -1
  115. package/build/queries/placeholder-text.js.map +1 -1
  116. package/build/queries/role.d.ts +5 -5
  117. package/build/queries/role.js.map +1 -1
  118. package/build/queries/test-id.d.ts +1 -1
  119. package/build/queries/test-id.js.map +1 -1
  120. package/build/queries/text.d.ts +1 -1
  121. package/build/queries/text.js.map +1 -1
  122. package/build/queries/unsafe-props.d.ts +6 -12
  123. package/build/queries/unsafe-props.js.map +1 -1
  124. package/build/queries/unsafe-type.d.ts +2 -1
  125. package/build/queries/unsafe-type.js +2 -0
  126. package/build/queries/unsafe-type.js.map +1 -1
  127. package/build/render-act.js +2 -2
  128. package/build/render-act.js.map +1 -1
  129. package/build/render-hook.d.ts +16 -6
  130. package/build/render-hook.js +21 -21
  131. package/build/render-hook.js.map +1 -1
  132. package/build/render.d.ts +12 -12
  133. package/build/render.js +9 -18
  134. package/build/render.js.map +1 -1
  135. package/build/screen.d.ts +1 -1
  136. package/build/screen.js.map +1 -1
  137. package/build/tsconfig.release.tsbuildinfo +1 -1
  138. package/build/user-event/clear.d.ts +2 -2
  139. package/build/user-event/clear.js +2 -2
  140. package/build/user-event/clear.js.map +1 -1
  141. package/build/user-event/event-builder/base.d.ts +2 -2
  142. package/build/user-event/event-builder/base.js.map +1 -1
  143. package/build/user-event/event-builder/scroll-view.d.ts +1 -1
  144. package/build/user-event/event-builder/scroll-view.js.map +1 -1
  145. package/build/user-event/event-builder/text-input.d.ts +2 -2
  146. package/build/user-event/event-builder/text-input.js.map +1 -1
  147. package/build/user-event/index.d.ts +4 -4
  148. package/build/user-event/index.js.map +1 -1
  149. package/build/user-event/paste.d.ts +2 -2
  150. package/build/user-event/paste.js.map +1 -1
  151. package/build/user-event/press/index.d.ts +1 -1
  152. package/build/user-event/press/index.js.map +1 -1
  153. package/build/user-event/press/press.d.ts +2 -2
  154. package/build/user-event/press/press.js +2 -2
  155. package/build/user-event/press/press.js.map +1 -1
  156. package/build/user-event/scroll/index.d.ts +1 -1
  157. package/build/user-event/scroll/index.js.map +1 -1
  158. package/build/user-event/scroll/scroll-to.d.ts +3 -3
  159. package/build/user-event/scroll/scroll-to.js +1 -1
  160. package/build/user-event/scroll/scroll-to.js.map +1 -1
  161. package/build/user-event/scroll/utils.d.ts +1 -1
  162. package/build/user-event/scroll/utils.js.map +1 -1
  163. package/build/user-event/setup/setup.d.ts +4 -4
  164. package/build/user-event/setup/setup.js.map +1 -1
  165. package/build/user-event/type/type.d.ts +2 -2
  166. package/build/user-event/type/type.js +3 -3
  167. package/build/user-event/type/type.js.map +1 -1
  168. package/build/user-event/utils/content-size.d.ts +1 -1
  169. package/build/user-event/utils/content-size.js.map +1 -1
  170. package/build/user-event/utils/dispatch-event.d.ts +1 -1
  171. package/build/user-event/utils/dispatch-event.js.map +1 -1
  172. package/build/user-event/utils/wait.d.ts +6 -2
  173. package/build/user-event/utils/wait.js +1 -1
  174. package/build/user-event/utils/wait.js.map +1 -1
  175. package/build/wait-for-element-to-be-removed.js +1 -1
  176. package/build/wait-for-element-to-be-removed.js.map +1 -1
  177. package/build/wait-for.js +1 -4
  178. package/build/wait-for.js.map +1 -1
  179. package/build/within.d.ts +4 -4
  180. package/build/within.js +5 -5
  181. package/build/within.js.map +1 -1
  182. package/package.json +9 -8
  183. package/typings/index.flow.js +28 -32
  184. package/build/helpers/format-default.js.map +0 -1
  185. package/build/helpers/format.d.ts +0 -7
  186. package/build/helpers/format.js +0 -31
  187. package/build/helpers/format.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"role.js","names":["_accessibility","require","_findAll","_matchAccessibilityState","_matchAccessibilityValue","_matchStringProp","_within","_makeQueries","matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","normalizedRole","normalizeRole","findAll","isAccessibilityElement","matchStringProp","getRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessibilityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole","exports"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport type { AccessibilityRole, Role } from 'react-native';\nimport {\n accessibilityStateKeys,\n accessibilityValueKeys,\n getRole,\n isAccessibilityElement,\n normalizeRole,\n} from '../helpers/accessibility';\nimport { findAll } from '../helpers/find-all';\nimport {\n AccessibilityStateMatcher,\n matchAccessibilityState,\n} from '../helpers/matchers/match-accessibility-state';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/match-accessibility-value';\nimport { matchStringProp } from '../helpers/matchers/match-string-prop';\nimport type { TextMatch } from '../matches';\nimport { StringWithAutocomplete } from '../types';\nimport { getQueriesForElement } from '../within';\nimport { makeQueries } from './make-queries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { CommonQueryOptions } from './options';\n\nexport type ByRoleMatcher = StringWithAutocomplete<AccessibilityRole | Role> | RegExp;\n\nexport type ByRoleOptions = CommonQueryOptions &\n AccessibilityStateMatcher & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\n };\n\nconst matchAccessibleNameIfNeeded = (node: ReactTestInstance, name?: TextMatch) => {\n if (name == null) return true;\n\n const { queryAllByText, queryAllByLabelText } = getQueriesForElement(node);\n return queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0;\n};\n\nconst matchAccessibleStateIfNeeded = (node: ReactTestInstance, options?: ByRoleOptions) => {\n return options != null ? matchAccessibilityState(node, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (\n node: ReactTestInstance,\n value?: AccessibilityValueMatcher,\n) => {\n return value != null ? matchAccessibilityValue(node, value) : true;\n};\n\nconst queryAllByRole = (\n instance: ReactTestInstance,\n): QueryAllByQuery<ByRoleMatcher, ByRoleOptions> =>\n function queryAllByRoleFn(role, options) {\n const normalizedRole = typeof role === 'string' ? normalizeRole(role) : role;\n return findAll(\n instance,\n (node) =>\n // run the cheapest checks first, and early exit to avoid unneeded computations\n isAccessibilityElement(node) &&\n matchStringProp(getRole(node), normalizedRole) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibilityValueIfNeeded(node, options?.value) &&\n matchAccessibleNameIfNeeded(node, options?.name),\n options,\n );\n };\n\nconst formatQueryParams = (role: TextMatch, options: ByRoleOptions = {}) => {\n const params = [`role: ${String(role)}`];\n\n if (options.name) {\n params.push(`name: ${String(options.name)}`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n params.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n accessibilityValueKeys.forEach((valueKey) => {\n if (options?.value?.[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${formatQueryParams(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${formatQueryParams(role, options)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<ByRoleMatcher, ByRoleOptions>;\n getAllByRole: GetAllByQuery<ByRoleMatcher, ByRoleOptions>;\n queryByRole: QueryByQuery<ByRoleMatcher, ByRoleOptions>;\n queryAllByRole: QueryAllByQuery<ByRoleMatcher, ByRoleOptions>;\n findByRole: FindByQuery<ByRoleMatcher, ByRoleOptions>;\n findAllByRole: FindAllByQuery<ByRoleMatcher, ByRoleOptions>;\n};\n\nexport const bindByRoleQueries = (instance: ReactTestInstance): ByRoleQueries => ({\n getByRole: getBy(instance),\n getAllByRole: getAllBy(instance),\n queryByRole: queryBy(instance),\n queryAllByRole: queryAllBy(instance),\n findBy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EAAE;AAEpE,MAAM2B,eAAe,GAAGA,CAACnB,IAAe,EAAER,OAAuB,KAC/D,kCAAkCe,iBAAiB,CAACP,IAAI,EAAER,OAAO,CAAC,EAAE;AAEtE,MAAM;EAAE4B,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E7B,cAAc,EACdsB,eAAe,EACfD,gBACF,CAAC;AAWM,MAAMS,iBAAiB,GAAI7B,QAA2B,KAAqB;EAChF8B,SAAS,EAAER,KAAK,CAACtB,QAAQ,CAAC;EAC1B+B,YAAY,EAAER,QAAQ,CAACvB,QAAQ,CAAC;EAChCgC,WAAW,EAAER,OAAO,CAACxB,QAAQ,CAAC;EAC9BD,cAAc,EAAE0B,UAAU,CAACzB,QAAQ,CAAC;EACpCiC,UAAU,EAAEP,MAAM,CAAC1B,QAAQ,CAAC;EAC5BkC,aAAa,EAAEP,SAAS,CAAC3B,QAAQ;AACnC,CAAC,CAAC;AAACmC,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"role.js","names":["_accessibility","require","_findAll","_matchAccessibilityState","_matchAccessibilityValue","_matchStringProp","_within","_makeQueries","matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","normalizedRole","normalizeRole","findAll","isAccessibilityElement","matchStringProp","getRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessibilityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole","exports"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { AccessibilityRole, Role } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport {\n accessibilityStateKeys,\n accessibilityValueKeys,\n getRole,\n isAccessibilityElement,\n normalizeRole,\n} from '../helpers/accessibility';\nimport { findAll } from '../helpers/find-all';\nimport type { AccessibilityStateMatcher } from '../helpers/matchers/match-accessibility-state';\nimport { matchAccessibilityState } from '../helpers/matchers/match-accessibility-state';\nimport type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport { matchAccessibilityValue } from '../helpers/matchers/match-accessibility-value';\nimport { matchStringProp } from '../helpers/matchers/match-string-prop';\nimport type { TextMatch } from '../matches';\nimport type { StringWithAutocomplete } from '../types';\nimport { getQueriesForElement } from '../within';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\nexport type ByRoleMatcher = StringWithAutocomplete<AccessibilityRole | Role> | RegExp;\n\nexport type ByRoleOptions = CommonQueryOptions &\n AccessibilityStateMatcher & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\n };\n\nconst matchAccessibleNameIfNeeded = (node: ReactTestInstance, name?: TextMatch) => {\n if (name == null) return true;\n\n const { queryAllByText, queryAllByLabelText } = getQueriesForElement(node);\n return queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0;\n};\n\nconst matchAccessibleStateIfNeeded = (node: ReactTestInstance, options?: ByRoleOptions) => {\n return options != null ? matchAccessibilityState(node, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (\n node: ReactTestInstance,\n value?: AccessibilityValueMatcher,\n) => {\n return value != null ? matchAccessibilityValue(node, value) : true;\n};\n\nconst queryAllByRole = (\n instance: ReactTestInstance,\n): QueryAllByQuery<ByRoleMatcher, ByRoleOptions> =>\n function queryAllByRoleFn(role, options) {\n const normalizedRole = typeof role === 'string' ? normalizeRole(role) : role;\n return findAll(\n instance,\n (node) =>\n // run the cheapest checks first, and early exit to avoid unneeded computations\n isAccessibilityElement(node) &&\n matchStringProp(getRole(node), normalizedRole) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibilityValueIfNeeded(node, options?.value) &&\n matchAccessibleNameIfNeeded(node, options?.name),\n options,\n );\n };\n\nconst formatQueryParams = (role: TextMatch, options: ByRoleOptions = {}) => {\n const params = [`role: ${String(role)}`];\n\n if (options.name) {\n params.push(`name: ${String(options.name)}`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n params.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n accessibilityValueKeys.forEach((valueKey) => {\n if (options?.value?.[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${formatQueryParams(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${formatQueryParams(role, options)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<ByRoleMatcher, ByRoleOptions>;\n getAllByRole: GetAllByQuery<ByRoleMatcher, ByRoleOptions>;\n queryByRole: QueryByQuery<ByRoleMatcher, ByRoleOptions>;\n queryAllByRole: QueryAllByQuery<ByRoleMatcher, ByRoleOptions>;\n findByRole: FindByQuery<ByRoleMatcher, ByRoleOptions>;\n findAllByRole: FindAllByQuery<ByRoleMatcher, ByRoleOptions>;\n};\n\nexport const bindByRoleQueries = (instance: ReactTestInstance): ByRoleQueries => ({\n getByRole: getBy(instance),\n getAllByRole: getAllBy(instance),\n queryByRole: queryBy(instance),\n queryAllByRole: queryAllBy(instance),\n findByRole: findBy(instance),\n findAllByRole: findAllBy(instance),\n});\n"],"mappings":";;;;;;AAEA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KAC/D,kCAAkCe,iBAAiB,CAACP,IAAI,EAAER,OAAO,CAAC,EAAE;AAEtE,MAAM;EAAE4B,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E7B,cAAc,EACdsB,eAAe,EACfD,gBACF,CAAC;AAWM,MAAMS,iBAAiB,GAAI7B,QAA2B,KAAqB;EAChF8B,SAAS,EAAER,KAAK,CAACtB,QAAQ,CAAC;EAC1B+B,YAAY,EAAER,QAAQ,CAACvB,QAAQ,CAAC;EAChCgC,WAAW,EAAER,OAAO,CAACxB,QAAQ,CAAC;EAC9BD,cAAc,EAAE0B,UAAU,CAACzB,QAAQ,CAAC;EACpCiC,UAAU,EAAEP,MAAM,CAAC1B,QAAQ,CAAC;EAC5BkC,aAAa,EAAEP,SAAS,CAAC3B,QAAQ;AACnC,CAAC,CAAC;AAACmC,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch, TextMatchOptions } from '../matches';
2
+ import type { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
4
4
  import type { CommonQueryOptions } from './options';
5
5
  type ByTestIdOptions = CommonQueryOptions & TextMatchOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","node","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","instance","queryAllByTestIdFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId","exports"],"sources":["../../src/queries/test-id.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './make-queries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchTestId = (\n node: ReactTestInstance,\n testId: TextMatch,\n options: TextMatchOptions = {},\n) => {\n const { exact, normalizer } = options;\n return matches(testId, node.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (\n instance: ReactTestInstance,\n): QueryAllByQuery<TextMatch, ByTestIdOptions> =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(instance, (node) => matchTestId(node, testId, queryOptions), queryOptions);\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (instance: ReactTestInstance): ByTestIdQueries => ({\n getByTestId: getBy(instance),\n getAllByTestId: getAllBy(instance),\n queryByTestId: queryBy(instance),\n queryAllByTestId: queryAllBy(instance),\n findByTestId: findBy(instance),\n findAllByTestId: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAA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B,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","node","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","instance","queryAllByTestIdFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId","exports"],"sources":["../../src/queries/test-id.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchTestId = (\n node: ReactTestInstance,\n testId: TextMatch,\n options: TextMatchOptions = {},\n) => {\n const { exact, normalizer } = options;\n return matches(testId, node.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (\n instance: ReactTestInstance,\n): QueryAllByQuery<TextMatch, ByTestIdOptions> =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(instance, (node) => matchTestId(node, testId, queryOptions), queryOptions);\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (instance: ReactTestInstance): ByTestIdQueries => ({\n getByTestId: getBy(instance),\n getAllByTestId: getAllBy(instance),\n queryByTestId: queryBy(instance),\n queryAllByTestId: queryAllBy(instance),\n findByTestId: findBy(instance),\n findAllByTestId: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,YAAA,GAAAF,OAAA;AAKA,MAAMG,WAAW,GAAGA,CAClBC,IAAuB,EACvBC,MAAiB,EACjBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,MAAM,EAAED,IAAI,CAACM,KAAK,CAACC,MAAM,EAAEH,UAAU,EAAED,KAAK,CAAC;AAC9D,CAAC;AAED,MAAMK,gBAAgB,GACpBC,QAA2B,IAE3B,SAASC,kBAAkBA,CAACT,MAAM,EAAEU,YAAY,EAAE;EAChD,OAAO,IAAAC,gBAAO,EAACH,QAAQ,EAAGT,IAAI,IAAKD,WAAW,CAACC,IAAI,EAAEC,MAAM,EAAEU,YAAY,CAAC,EAAEA,YAAY,CAAC;AAC3F,CAAC;AAEH,MAAME,gBAAgB,GAAIZ,MAAiB,IACzC,wCAAwCa,MAAM,CAACb,MAAM,CAAC,EAAE;AAC1D,MAAMc,eAAe,GAAId,MAAiB,IACxC,0CAA0Ca,MAAM,CAACb,MAAM,CAAC,EAAE;AAE5D,MAAM;EAAEe,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,gBAAgB,EAChBO,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,mBAAmB,GAAId,QAA2B,KAAuB;EACpFe,WAAW,EAAER,KAAK,CAACP,QAAQ,CAAC;EAC5BgB,cAAc,EAAER,QAAQ,CAACR,QAAQ,CAAC;EAClCiB,aAAa,EAAER,OAAO,CAACT,QAAQ,CAAC;EAChCD,gBAAgB,EAAEW,UAAU,CAACV,QAAQ,CAAC;EACtCkB,YAAY,EAAEP,MAAM,CAACX,QAAQ,CAAC;EAC9BmB,eAAe,EAAEP,SAAS,CAACZ,QAAQ;AACrC,CAAC,CAAC;AAACoB,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch, TextMatchOptions } from '../matches';
2
+ import type { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
4
4
  import type { CommonQueryOptions } from './options';
5
5
  type ByTextOptions = CommonQueryOptions & TextMatchOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","instance","queryAllByTextFn","text","options","findAll","node","isHostText","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText","exports"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport { isHostText } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/match-text-content';\nimport { TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './make-queries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (instance: ReactTestInstance): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(instance, (node) => isHostText(node) && matchTextContent(node, text, options), {\n ...options,\n matchDeepestOnly: true,\n });\n };\n\nconst getMultipleError = (text: TextMatch) => `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) => `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (instance: ReactTestInstance): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAaA,MAAMI,cAAc,GAAIC,QAA2B,IACjD,SAASC,gBAAgBA,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,OAAO,IAAAC,gBAAO,EAACJ,QAAQ,EAAGK,IAAI,IAAK,IAAAC,8BAAU,EAACD,IAAI,CAAC,IAAI,IAAAE,kCAAgB,EAACF,IAAI,EAAEH,IAAI,EAAEC,OAAO,CAAC,EAAE;IAC5F,GAAGA,OAAO;IACVK,gBAAgB,EAAE;EACpB,CAAC,CAAC;AACJ,CAAC;AAEH,MAAMC,gBAAgB,GAAIP,IAAe,IAAK,sCAAsCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAElG,MAAMS,eAAe,GAAIT,IAAe,IAAK,wCAAwCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAEnG,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EnB,cAAc,EACdY,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,iBAAiB,GAAInB,QAA2B,KAAqB;EAChFoB,SAAS,EAAER,KAAK,CAACZ,QAAQ,CAAC;EAC1BqB,YAAY,EAAER,QAAQ,CAACb,QAAQ,CAAC;EAChCsB,WAAW,EAAER,OAAO,CAACd,QAAQ,CAAC;EAC9BD,cAAc,EAAEgB,UAAU,CAACf,QAAQ,CAAC;EACpCuB,UAAU,EAAEP,MAAM,CAAChB,QAAQ,CAAC;EAC5BwB,aAAa,EAAEP,SAAS,CAACjB,QAAQ;AACnC,CAAC,CAAC;AAACyB,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","instance","queryAllByTextFn","text","options","findAll","node","isHostText","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText","exports"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport { isHostText } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/match-text-content';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (instance: ReactTestInstance): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(instance, (node) => isHostText(node) && matchTextContent(node, text, options), {\n ...options,\n matchDeepestOnly: true,\n });\n };\n\nconst getMultipleError = (text: TextMatch) => `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) => `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (instance: ReactTestInstance): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAUA,IAAAG,YAAA,GAAAH,OAAA;AAKA,MAAMI,cAAc,GAAIC,QAA2B,IACjD,SAASC,gBAAgBA,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,OAAO,IAAAC,gBAAO,EAACJ,QAAQ,EAAGK,IAAI,IAAK,IAAAC,8BAAU,EAACD,IAAI,CAAC,IAAI,IAAAE,kCAAgB,EAACF,IAAI,EAAEH,IAAI,EAAEC,OAAO,CAAC,EAAE;IAC5F,GAAGA,OAAO;IACVK,gBAAgB,EAAE;EACpB,CAAC,CAAC;AACJ,CAAC;AAEH,MAAMC,gBAAgB,GAAIP,IAAe,IAAK,sCAAsCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAElG,MAAMS,eAAe,GAAIT,IAAe,IAAK,wCAAwCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAEnG,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EnB,cAAc,EACdY,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,iBAAiB,GAAInB,QAA2B,KAAqB;EAChFoB,SAAS,EAAER,KAAK,CAACZ,QAAQ,CAAC;EAC1BqB,YAAY,EAAER,QAAQ,CAACb,QAAQ,CAAC;EAChCsB,WAAW,EAAER,OAAO,CAACd,QAAQ,CAAC;EAC9BD,cAAc,EAAEgB,UAAU,CAACf,QAAQ,CAAC;EACpCuB,UAAU,EAAEP,MAAM,CAAChB,QAAQ,CAAC;EAC5BwB,aAAa,EAAEP,SAAS,CAACjB,QAAQ;AACnC,CAAC,CAAC;AAACyB,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -1,16 +1,10 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
+ type Props = Record<string, unknown>;
2
3
  export type UnsafeByPropsQueries = {
3
- UNSAFE_getByProps: (props: {
4
- [key: string]: any;
5
- }) => ReactTestInstance;
6
- UNSAFE_getAllByProps: (props: {
7
- [key: string]: any;
8
- }) => Array<ReactTestInstance>;
9
- UNSAFE_queryByProps: (props: {
10
- [key: string]: any;
11
- }) => ReactTestInstance | null;
12
- UNSAFE_queryAllByProps: (props: {
13
- [key: string]: any;
14
- }) => Array<ReactTestInstance>;
4
+ UNSAFE_getByProps: (props: Props) => ReactTestInstance;
5
+ UNSAFE_getAllByProps: (props: Props) => Array<ReactTestInstance>;
6
+ UNSAFE_queryByProps: (props: Props) => ReactTestInstance | null;
7
+ UNSAFE_queryAllByProps: (props: Props) => Array<ReactTestInstance>;
15
8
  };
16
9
  export declare const bindUnsafeByPropsQueries: (instance: ReactTestInstance) => UnsafeByPropsQueries;
10
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"unsafe-props.js","names":["_prettyFormat","_interopRequireDefault","require","_errors","e","__esModule","default","UNSAFE_getByProps","instance","getByPropsFn","props","findByProps","error","ErrorWithStack","prepareErrorMessage","UNSAFE_getAllByProps","getAllByPropsFn","results","findAllByProps","length","prettyFormat","UNSAFE_queryByProps","queryByPropsFn","createQueryByError","UNSAFE_queryAllByProps","bindUnsafeByPropsQueries","exports"],"sources":["../../src/queries/unsafe-props.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport prettyFormat from 'pretty-format';\nimport { ErrorWithStack, prepareErrorMessage } from '../helpers/errors';\nimport { createQueryByError } from '../helpers/errors';\n\nconst UNSAFE_getByProps = (\n instance: ReactTestInstance,\n): ((props: { [propName: string]: any }) => ReactTestInstance) =>\n function getByPropsFn(props: { [propName: string]: any }) {\n try {\n return instance.findByProps(props);\n } catch (error) {\n throw new ErrorWithStack(prepareErrorMessage(error), getByPropsFn);\n }\n };\n\nconst UNSAFE_getAllByProps = (\n instance: ReactTestInstance,\n): ((props: { [propName: string]: any }) => Array<ReactTestInstance>) =>\n function getAllByPropsFn(props: { [propName: string]: any }) {\n const results = instance.findAllByProps(props);\n if (results.length === 0) {\n throw new ErrorWithStack(\n `No instances found with props:\\n${prettyFormat(props)}`,\n getAllByPropsFn,\n );\n }\n return results;\n };\n\nconst UNSAFE_queryByProps = (\n instance: ReactTestInstance,\n): ((props: { [propName: string]: any }) => ReactTestInstance | null) =>\n function queryByPropsFn(props: { [propName: string]: any }) {\n try {\n return UNSAFE_getByProps(instance)(props);\n } catch (error) {\n return createQueryByError(error, queryByPropsFn);\n }\n };\n\nconst UNSAFE_queryAllByProps =\n (\n instance: ReactTestInstance,\n ): ((props: { [propName: string]: any }) => Array<ReactTestInstance>) =>\n (props: { [propName: string]: any }) => {\n try {\n return UNSAFE_getAllByProps(instance)(props);\n } catch {\n return [];\n }\n };\n\n// Unsafe aliases\nexport type UnsafeByPropsQueries = {\n UNSAFE_getByProps: (props: { [key: string]: any }) => ReactTestInstance;\n UNSAFE_getAllByProps: (props: { [key: string]: any }) => Array<ReactTestInstance>;\n UNSAFE_queryByProps: (props: { [key: string]: any }) => ReactTestInstance | null;\n UNSAFE_queryAllByProps: (props: { [key: string]: any }) => Array<ReactTestInstance>;\n};\n\n// TODO: migrate to makeQueries pattern\nexport const bindUnsafeByPropsQueries = (instance: ReactTestInstance): UnsafeByPropsQueries => ({\n UNSAFE_getByProps: UNSAFE_getByProps(instance),\n UNSAFE_getAllByProps: UNSAFE_getAllByProps(instance),\n UNSAFE_queryByProps: UNSAFE_queryByProps(instance),\n UNSAFE_queryAllByProps: UNSAFE_queryAllByProps(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAwE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGxE,MAAMG,iBAAiB,GACrBC,QAA2B,IAE3B,SAASC,YAAYA,CAACC,KAAkC,EAAE;EACxD,IAAI;IACF,OAAOF,QAAQ,CAACG,WAAW,CAACD,KAAK,CAAC;EACpC,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAM,IAAIC,sBAAc,CAAC,IAAAC,2BAAmB,EAACF,KAAK,CAAC,EAAEH,YAAY,CAAC;EACpE;AACF,CAAC;AAEH,MAAMM,oBAAoB,GACxBP,QAA2B,IAE3B,SAASQ,eAAeA,CAACN,KAAkC,EAAE;EAC3D,MAAMO,OAAO,GAAGT,QAAQ,CAACU,cAAc,CAACR,KAAK,CAAC;EAC9C,IAAIO,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB,MAAM,IAAIN,sBAAc,CACtB,mCAAmC,IAAAO,qBAAY,EAACV,KAAK,CAAC,EAAE,EACxDM,eACF,CAAC;EACH;EACA,OAAOC,OAAO;AAChB,CAAC;AAEH,MAAMI,mBAAmB,GACvBb,QAA2B,IAE3B,SAASc,cAAcA,CAACZ,KAAkC,EAAE;EAC1D,IAAI;IACF,OAAOH,iBAAiB,CAACC,QAAQ,CAAC,CAACE,KAAK,CAAC;EAC3C,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,OAAO,IAAAW,0BAAkB,EAACX,KAAK,EAAEU,cAAc,CAAC;EAClD;AACF,CAAC;AAEH,MAAME,sBAAsB,GAExBhB,QAA2B,IAE5BE,KAAkC,IAAK;EACtC,IAAI;IACF,OAAOK,oBAAoB,CAACP,QAAQ,CAAC,CAACE,KAAK,CAAC;EAC9C,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF,CAAC;;AAEH;;AAQA;AACO,MAAMe,wBAAwB,GAAIjB,QAA2B,KAA4B;EAC9FD,iBAAiB,EAAEA,iBAAiB,CAACC,QAAQ,CAAC;EAC9CO,oBAAoB,EAAEA,oBAAoB,CAACP,QAAQ,CAAC;EACpDa,mBAAmB,EAAEA,mBAAmB,CAACb,QAAQ,CAAC;EAClDgB,sBAAsB,EAAEA,sBAAsB,CAAChB,QAAQ;AACzD,CAAC,CAAC;AAACkB,OAAA,CAAAD,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"file":"unsafe-props.js","names":["_prettyFormat","_interopRequireDefault","require","_errors","e","__esModule","default","UNSAFE_getByProps","instance","getByPropsFn","props","findByProps","error","ErrorWithStack","prepareErrorMessage","UNSAFE_getAllByProps","getAllByPropsFn","results","findAllByProps","length","prettyFormat","UNSAFE_queryByProps","queryByPropsFn","createQueryByError","UNSAFE_queryAllByProps","bindUnsafeByPropsQueries","exports"],"sources":["../../src/queries/unsafe-props.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport prettyFormat from 'pretty-format';\nimport { ErrorWithStack, prepareErrorMessage } from '../helpers/errors';\nimport { createQueryByError } from '../helpers/errors';\n\ntype Props = Record<string, unknown>;\n\nconst UNSAFE_getByProps = (instance: ReactTestInstance): ((props: Props) => ReactTestInstance) =>\n function getByPropsFn(props: Props) {\n try {\n return instance.findByProps(props);\n } catch (error) {\n throw new ErrorWithStack(prepareErrorMessage(error), getByPropsFn);\n }\n };\n\nconst UNSAFE_getAllByProps = (\n instance: ReactTestInstance,\n): ((props: Props) => Array<ReactTestInstance>) =>\n function getAllByPropsFn(props: Props) {\n const results = instance.findAllByProps(props);\n if (results.length === 0) {\n throw new ErrorWithStack(\n `No instances found with props:\\n${prettyFormat(props)}`,\n getAllByPropsFn,\n );\n }\n return results;\n };\n\nconst UNSAFE_queryByProps = (\n instance: ReactTestInstance,\n): ((props: Props) => ReactTestInstance | null) =>\n function queryByPropsFn(props: Props) {\n try {\n return UNSAFE_getByProps(instance)(props);\n } catch (error) {\n return createQueryByError(error, queryByPropsFn);\n }\n };\n\nconst UNSAFE_queryAllByProps =\n (instance: ReactTestInstance): ((props: Props) => Array<ReactTestInstance>) =>\n (props: Props) => {\n try {\n return UNSAFE_getAllByProps(instance)(props);\n } catch {\n return [];\n }\n };\n\n// Unsafe aliases\nexport type UnsafeByPropsQueries = {\n UNSAFE_getByProps: (props: Props) => ReactTestInstance;\n UNSAFE_getAllByProps: (props: Props) => Array<ReactTestInstance>;\n UNSAFE_queryByProps: (props: Props) => ReactTestInstance | null;\n UNSAFE_queryAllByProps: (props: Props) => Array<ReactTestInstance>;\n};\n\n// TODO: migrate to makeQueries pattern\nexport const bindUnsafeByPropsQueries = (instance: ReactTestInstance): UnsafeByPropsQueries => ({\n UNSAFE_getByProps: UNSAFE_getByProps(instance),\n UNSAFE_getAllByProps: UNSAFE_getAllByProps(instance),\n UNSAFE_queryByProps: UNSAFE_queryByProps(instance),\n UNSAFE_queryAllByProps: UNSAFE_queryAllByProps(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAwE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKxE,MAAMG,iBAAiB,GAAIC,QAA2B,IACpD,SAASC,YAAYA,CAACC,KAAY,EAAE;EAClC,IAAI;IACF,OAAOF,QAAQ,CAACG,WAAW,CAACD,KAAK,CAAC;EACpC,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAM,IAAIC,sBAAc,CAAC,IAAAC,2BAAmB,EAACF,KAAK,CAAC,EAAEH,YAAY,CAAC;EACpE;AACF,CAAC;AAEH,MAAMM,oBAAoB,GACxBP,QAA2B,IAE3B,SAASQ,eAAeA,CAACN,KAAY,EAAE;EACrC,MAAMO,OAAO,GAAGT,QAAQ,CAACU,cAAc,CAACR,KAAK,CAAC;EAC9C,IAAIO,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB,MAAM,IAAIN,sBAAc,CACtB,mCAAmC,IAAAO,qBAAY,EAACV,KAAK,CAAC,EAAE,EACxDM,eACF,CAAC;EACH;EACA,OAAOC,OAAO;AAChB,CAAC;AAEH,MAAMI,mBAAmB,GACvBb,QAA2B,IAE3B,SAASc,cAAcA,CAACZ,KAAY,EAAE;EACpC,IAAI;IACF,OAAOH,iBAAiB,CAACC,QAAQ,CAAC,CAACE,KAAK,CAAC;EAC3C,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,OAAO,IAAAW,0BAAkB,EAACX,KAAK,EAAEU,cAAc,CAAC;EAClD;AACF,CAAC;AAEH,MAAME,sBAAsB,GACzBhB,QAA2B,IAC3BE,KAAY,IAAK;EAChB,IAAI;IACF,OAAOK,oBAAoB,CAACP,QAAQ,CAAC,CAACE,KAAK,CAAC;EAC9C,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF,CAAC;;AAEH;;AAQA;AACO,MAAMe,wBAAwB,GAAIjB,QAA2B,KAA4B;EAC9FD,iBAAiB,EAAEA,iBAAiB,CAACC,QAAQ,CAAC;EAC9CO,oBAAoB,EAAEA,oBAAoB,CAACP,QAAQ,CAAC;EACpDa,mBAAmB,EAAEA,mBAAmB,CAACb,QAAQ,CAAC;EAClDgB,sBAAsB,EAAEA,sBAAsB,CAAChB,QAAQ;AACzD,CAAC,CAAC;AAACkB,OAAA,CAAAD,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1,5 +1,6 @@
1
+ import type * as React from 'react';
1
2
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import * as React from 'react';
3
+ export type UnsafeComponentType = React.ComponentType<any>;
3
4
  export type UnsafeByTypeQueries = {
4
5
  UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
5
6
  UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindUnsafeByTypeQueries = void 0;
7
7
  var _errors = require("../helpers/errors");
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+
8
10
  const UNSAFE_getByType = instance => function getByTypeFn(type) {
9
11
  try {
10
12
  return instance.findByType(type);
@@ -1 +1 @@
1
- {"version":3,"file":"unsafe-type.js","names":["_errors","require","UNSAFE_getByType","instance","getByTypeFn","type","findByType","error","ErrorWithStack","prepareErrorMessage","UNSAFE_getAllByType","getAllByTypeFn","results","findAllByType","length","UNSAFE_queryByType","queryByTypeFn","createQueryByError","UNSAFE_queryAllByType","bindUnsafeByTypeQueries","exports"],"sources":["../../src/queries/unsafe-type.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport * as React from 'react';\nimport { ErrorWithStack, prepareErrorMessage } from '../helpers/errors';\nimport { createQueryByError } from '../helpers/errors';\n\nconst UNSAFE_getByType = (\n instance: ReactTestInstance,\n): ((type: React.ComponentType<any>) => ReactTestInstance) =>\n function getByTypeFn(type: React.ComponentType<any>) {\n try {\n return instance.findByType(type);\n } catch (error) {\n throw new ErrorWithStack(prepareErrorMessage(error), getByTypeFn);\n }\n };\n\nconst UNSAFE_getAllByType = (\n instance: ReactTestInstance,\n): ((type: React.ComponentType<any>) => Array<ReactTestInstance>) =>\n function getAllByTypeFn(type: React.ComponentType<any>) {\n const results = instance.findAllByType(type);\n if (results.length === 0) {\n throw new ErrorWithStack('No instances found', getAllByTypeFn);\n }\n return results;\n };\n\nconst UNSAFE_queryByType = (\n instance: ReactTestInstance,\n): ((type: React.ComponentType<any>) => ReactTestInstance | null) =>\n function queryByTypeFn(type: React.ComponentType<any>) {\n try {\n return UNSAFE_getByType(instance)(type);\n } catch (error) {\n return createQueryByError(error, queryByTypeFn);\n }\n };\n\nconst UNSAFE_queryAllByType =\n (instance: ReactTestInstance): ((type: React.ComponentType<any>) => Array<ReactTestInstance>) =>\n (type: React.ComponentType<any>) => {\n try {\n return UNSAFE_getAllByType(instance)(type);\n } catch {\n return [];\n }\n };\n\n// Unsafe aliases\nexport type UnsafeByTypeQueries = {\n UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;\n UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;\n UNSAFE_queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;\n UNSAFE_queryAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;\n};\n\n// TODO: migrate to makeQueries pattern\nexport const bindUnsafeByTypeQueries = (instance: ReactTestInstance): UnsafeByTypeQueries => ({\n UNSAFE_getByType: UNSAFE_getByType(instance),\n UNSAFE_getAllByType: UNSAFE_getAllByType(instance),\n UNSAFE_queryByType: UNSAFE_queryByType(instance),\n UNSAFE_queryAllByType: UNSAFE_queryAllByType(instance),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAGA,MAAMC,gBAAgB,GACpBC,QAA2B,IAE3B,SAASC,WAAWA,CAACC,IAA8B,EAAE;EACnD,IAAI;IACF,OAAOF,QAAQ,CAACG,UAAU,CAACD,IAAI,CAAC;EAClC,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAM,IAAIC,sBAAc,CAAC,IAAAC,2BAAmB,EAACF,KAAK,CAAC,EAAEH,WAAW,CAAC;EACnE;AACF,CAAC;AAEH,MAAMM,mBAAmB,GACvBP,QAA2B,IAE3B,SAASQ,cAAcA,CAACN,IAA8B,EAAE;EACtD,MAAMO,OAAO,GAAGT,QAAQ,CAACU,aAAa,CAACR,IAAI,CAAC;EAC5C,IAAIO,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB,MAAM,IAAIN,sBAAc,CAAC,oBAAoB,EAAEG,cAAc,CAAC;EAChE;EACA,OAAOC,OAAO;AAChB,CAAC;AAEH,MAAMG,kBAAkB,GACtBZ,QAA2B,IAE3B,SAASa,aAAaA,CAACX,IAA8B,EAAE;EACrD,IAAI;IACF,OAAOH,gBAAgB,CAACC,QAAQ,CAAC,CAACE,IAAI,CAAC;EACzC,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,OAAO,IAAAU,0BAAkB,EAACV,KAAK,EAAES,aAAa,CAAC;EACjD;AACF,CAAC;AAEH,MAAME,qBAAqB,GACxBf,QAA2B,IAC3BE,IAA8B,IAAK;EAClC,IAAI;IACF,OAAOK,mBAAmB,CAACP,QAAQ,CAAC,CAACE,IAAI,CAAC;EAC5C,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF,CAAC;;AAEH;;AAQA;AACO,MAAMc,uBAAuB,GAAIhB,QAA2B,KAA2B;EAC5FD,gBAAgB,EAAEA,gBAAgB,CAACC,QAAQ,CAAC;EAC5CO,mBAAmB,EAAEA,mBAAmB,CAACP,QAAQ,CAAC;EAClDY,kBAAkB,EAAEA,kBAAkB,CAACZ,QAAQ,CAAC;EAChDe,qBAAqB,EAAEA,qBAAqB,CAACf,QAAQ;AACvD,CAAC,CAAC;AAACiB,OAAA,CAAAD,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"file":"unsafe-type.js","names":["_errors","require","UNSAFE_getByType","instance","getByTypeFn","type","findByType","error","ErrorWithStack","prepareErrorMessage","UNSAFE_getAllByType","getAllByTypeFn","results","findAllByType","length","UNSAFE_queryByType","queryByTypeFn","createQueryByError","UNSAFE_queryAllByType","bindUnsafeByTypeQueries","exports"],"sources":["../../src/queries/unsafe-type.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { ErrorWithStack, prepareErrorMessage } from '../helpers/errors';\nimport { createQueryByError } from '../helpers/errors';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UnsafeComponentType = React.ComponentType<any>;\n\nconst UNSAFE_getByType = (\n instance: ReactTestInstance,\n): ((type: UnsafeComponentType) => ReactTestInstance) =>\n function getByTypeFn(type: UnsafeComponentType) {\n try {\n return instance.findByType(type);\n } catch (error) {\n throw new ErrorWithStack(prepareErrorMessage(error), getByTypeFn);\n }\n };\n\nconst UNSAFE_getAllByType = (\n instance: ReactTestInstance,\n): ((type: UnsafeComponentType) => Array<ReactTestInstance>) =>\n function getAllByTypeFn(type: UnsafeComponentType) {\n const results = instance.findAllByType(type);\n if (results.length === 0) {\n throw new ErrorWithStack('No instances found', getAllByTypeFn);\n }\n return results;\n };\n\nconst UNSAFE_queryByType = (\n instance: ReactTestInstance,\n): ((type: UnsafeComponentType) => ReactTestInstance | null) =>\n function queryByTypeFn(type: UnsafeComponentType) {\n try {\n return UNSAFE_getByType(instance)(type);\n } catch (error) {\n return createQueryByError(error, queryByTypeFn);\n }\n };\n\nconst UNSAFE_queryAllByType =\n (instance: ReactTestInstance): ((type: UnsafeComponentType) => Array<ReactTestInstance>) =>\n (type: UnsafeComponentType) => {\n try {\n return UNSAFE_getAllByType(instance)(type);\n } catch {\n return [];\n }\n };\n\n// Unsafe aliases\nexport type UnsafeByTypeQueries = {\n UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;\n UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;\n UNSAFE_queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;\n UNSAFE_queryAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;\n};\n\n// TODO: migrate to makeQueries pattern\nexport const bindUnsafeByTypeQueries = (instance: ReactTestInstance): UnsafeByTypeQueries => ({\n UNSAFE_getByType: UNSAFE_getByType(instance),\n UNSAFE_getAllByType: UNSAFE_getAllByType(instance),\n UNSAFE_queryByType: UNSAFE_queryByType(instance),\n UNSAFE_queryAllByType: UNSAFE_queryAllByType(instance),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAGA;;AAGA,MAAMC,gBAAgB,GACpBC,QAA2B,IAE3B,SAASC,WAAWA,CAACC,IAAyB,EAAE;EAC9C,IAAI;IACF,OAAOF,QAAQ,CAACG,UAAU,CAACD,IAAI,CAAC;EAClC,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAM,IAAIC,sBAAc,CAAC,IAAAC,2BAAmB,EAACF,KAAK,CAAC,EAAEH,WAAW,CAAC;EACnE;AACF,CAAC;AAEH,MAAMM,mBAAmB,GACvBP,QAA2B,IAE3B,SAASQ,cAAcA,CAACN,IAAyB,EAAE;EACjD,MAAMO,OAAO,GAAGT,QAAQ,CAACU,aAAa,CAACR,IAAI,CAAC;EAC5C,IAAIO,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB,MAAM,IAAIN,sBAAc,CAAC,oBAAoB,EAAEG,cAAc,CAAC;EAChE;EACA,OAAOC,OAAO;AAChB,CAAC;AAEH,MAAMG,kBAAkB,GACtBZ,QAA2B,IAE3B,SAASa,aAAaA,CAACX,IAAyB,EAAE;EAChD,IAAI;IACF,OAAOH,gBAAgB,CAACC,QAAQ,CAAC,CAACE,IAAI,CAAC;EACzC,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,OAAO,IAAAU,0BAAkB,EAACV,KAAK,EAAES,aAAa,CAAC;EACjD;AACF,CAAC;AAEH,MAAME,qBAAqB,GACxBf,QAA2B,IAC3BE,IAAyB,IAAK;EAC7B,IAAI;IACF,OAAOK,mBAAmB,CAACP,QAAQ,CAAC,CAACE,IAAI,CAAC;EAC5C,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF,CAAC;;AAEH;;AAQA;AACO,MAAMc,uBAAuB,GAAIhB,QAA2B,KAA2B;EAC5FD,gBAAgB,EAAEA,gBAAgB,CAACC,QAAQ,CAAC;EAC5CO,mBAAmB,EAAEA,mBAAmB,CAACP,QAAQ,CAAC;EAClDY,kBAAkB,EAAEA,kBAAkB,CAACZ,QAAQ,CAAC;EAChDe,qBAAqB,EAAEA,qBAAqB,CAACf,QAAQ;AACvD,CAAC,CAAC;AAACiB,OAAA,CAAAD,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -12,11 +12,11 @@ function renderWithAct(component, options) {
12
12
 
13
13
  // This will be called synchronously.
14
14
  void (0, _act.default)(() => {
15
- // @ts-expect-error TestRenderer.create is not typed correctly
15
+ // @ts-expect-error `TestRenderer.create` is not typed correctly
16
16
  renderer = _reactTestRenderer.default.create(component, options);
17
17
  });
18
18
 
19
- // @ts-ignore act is synchronous, so renderer is already initialized here
19
+ // @ts-expect-error: `act` is synchronous, so `renderer` is already initialized here
20
20
  return renderer;
21
21
  }
22
22
  //# sourceMappingURL=render-act.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-act.js","names":["_reactTestRenderer","_interopRequireDefault","require","_act","e","__esModule","default","renderWithAct","component","options","renderer","act","TestRenderer","create"],"sources":["../src/render-act.ts"],"sourcesContent":["import TestRenderer from 'react-test-renderer';\nimport type { ReactTestRenderer, TestRendererOptions } from 'react-test-renderer';\nimport act from './act';\n\nexport function renderWithAct(\n component: React.ReactElement,\n options?: Partial<TestRendererOptions>,\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n // This will be called synchronously.\n void act(() => {\n // @ts-expect-error TestRenderer.create is not typed correctly\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-ignore act is synchronous, so renderer is already initialized here\n return renderer;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjB,SAASG,aAAaA,CAC3BC,SAA6B,EAC7BC,OAAsC,EACnB;EACnB,IAAIC,QAA2B;;EAE/B;EACA,KAAK,IAAAC,YAAG,EAAC,MAAM;IACb;IACAD,QAAQ,GAAGE,0BAAY,CAACC,MAAM,CAACL,SAAS,EAAEC,OAAO,CAAC;EACpD,CAAC,CAAC;;EAEF;EACA,OAAOC,QAAQ;AACjB","ignoreList":[]}
1
+ {"version":3,"file":"render-act.js","names":["_reactTestRenderer","_interopRequireDefault","require","_act","e","__esModule","default","renderWithAct","component","options","renderer","act","TestRenderer","create"],"sources":["../src/render-act.ts"],"sourcesContent":["import type { ReactTestRenderer, TestRendererOptions } from 'react-test-renderer';\nimport TestRenderer from 'react-test-renderer';\nimport act from './act';\n\nexport function renderWithAct(\n component: React.ReactElement,\n options?: Partial<TestRendererOptions>,\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n // This will be called synchronously.\n void act(() => {\n // @ts-expect-error `TestRenderer.create` is not typed correctly\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-expect-error: `act` is synchronous, so `renderer` is already initialized here\n return renderer;\n}\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjB,SAASG,aAAaA,CAC3BC,SAA6B,EAC7BC,OAAsC,EACnB;EACnB,IAAIC,QAA2B;;EAE/B;EACA,KAAK,IAAAC,YAAG,EAAC,MAAM;IACb;IACAD,QAAQ,GAAGE,0BAAY,CAACC,MAAM,CAACL,SAAS,EAAEC,OAAO,CAAC;EACpD,CAAC,CAAC;;EAEF;EACA,OAAOC,QAAQ;AACjB","ignoreList":[]}
@@ -1,13 +1,23 @@
1
- import type { ComponentType } from 'react';
1
+ import * as React from 'react';
2
2
  export type RenderHookResult<Result, Props> = {
3
3
  rerender: (props: Props) => void;
4
- result: {
5
- current: Result;
6
- };
4
+ result: React.MutableRefObject<Result>;
7
5
  unmount: () => void;
8
6
  };
9
7
  export type RenderHookOptions<Props> = {
8
+ /**
9
+ * The initial props to pass to the hook.
10
+ */
10
11
  initialProps?: Props;
11
- wrapper?: ComponentType<any>;
12
+ /**
13
+ * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
14
+ * reusable custom render functions for common data providers.
15
+ */
16
+ wrapper?: React.ComponentType<any>;
17
+ /**
18
+ * Set to `false` to disable concurrent rendering.
19
+ * Otherwise `renderHook` will default to concurrent rendering.
20
+ */
21
+ concurrentRoot?: boolean;
12
22
  };
13
- export declare function renderHook<Result, Props>(renderCallback: (props: Props) => Result, options?: RenderHookOptions<Props>): RenderHookResult<Result, Props>;
23
+ export declare function renderHook<Result, Props>(hookToRender: (props: Props) => Result, options?: RenderHookOptions<Props>): RenderHookResult<Result, Props>;
@@ -4,42 +4,42 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderHook = renderHook;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var React = _interopRequireWildcard(require("react"));
8
8
  var _render = require("./render");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- function renderHook(renderCallback, options) {
11
- const initialProps = options?.initialProps;
12
- const wrapper = options?.wrapper;
13
- const result = /*#__PURE__*/_react.default.createRef();
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function renderHook(hookToRender, options) {
12
+ const {
13
+ initialProps,
14
+ ...renderOptions
15
+ } = options ?? {};
16
+ const result = /*#__PURE__*/React.createRef();
14
17
  function TestComponent({
15
- renderCallbackProps
18
+ hookProps
16
19
  }) {
17
- const renderResult = renderCallback(renderCallbackProps);
18
- _react.default.useEffect(() => {
20
+ const renderResult = hookToRender(hookProps);
21
+ React.useEffect(() => {
19
22
  result.current = renderResult;
20
23
  });
21
24
  return null;
22
25
  }
23
26
  const {
24
- rerender: baseRerender,
27
+ rerender: componentRerender,
25
28
  unmount
26
29
  } = (0, _render.renderInternal)(
27
30
  /*#__PURE__*/
28
31
  // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt
29
- _react.default.createElement(TestComponent, {
30
- renderCallbackProps: initialProps
31
- }), {
32
- wrapper
33
- });
34
- function rerender(rerenderCallbackProps) {
35
- return baseRerender(/*#__PURE__*/_react.default.createElement(TestComponent, {
36
- renderCallbackProps: rerenderCallbackProps
32
+ React.createElement(TestComponent, {
33
+ hookProps: initialProps
34
+ }), renderOptions);
35
+ function rerender(hookProps) {
36
+ return componentRerender(/*#__PURE__*/React.createElement(TestComponent, {
37
+ hookProps: hookProps
37
38
  }));
38
39
  }
39
-
40
- // @ts-expect-error result is ill typed because ref is initialized to null
41
40
  return {
42
- result,
41
+ // Result should already be set after the first render effects are run.
42
+ result: result,
43
43
  rerender,
44
44
  unmount
45
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"render-hook.js","names":["_react","_interopRequireDefault","require","_render","e","__esModule","default","renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","renderInternal","createElement","rerenderCallbackProps"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport { renderInternal } from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = {\n initialProps?: Props;\n wrapper?: ComponentType<any>;\n};\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({ renderCallbackProps }: { renderCallbackProps: Props }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = renderInternal(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n {\n wrapper,\n },\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(<TestComponent renderCallbackProps={rerenderCallbackProps} />);\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAanC,SAASG,UAAUA,CACxBC,cAAwC,EACxCC,OAAkC,EACD;EACjC,MAAMC,YAAY,GAAGD,OAAO,EAAEC,YAAY;EAC1C,MAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAO;EAEhC,MAAMC,MAA6C,gBAAGC,cAAK,CAACC,SAAS,CAAC,CAAC;EAEvE,SAASC,aAAaA,CAAC;IAAEC;EAAoD,CAAC,EAAE;IAC9E,MAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAmB,CAAC;IAExDH,cAAK,CAACK,SAAS,CAAC,MAAM;MACpBN,MAAM,CAACO,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAc;EAAA;EACxD;EACAvB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;IAACC,mBAAmB,EAAEN;EAAa,CAAE,CAAC,EACpD;IACEC;EACF,CACF,CAAC;EAED,SAASS,QAAQA,CAACK,qBAA4B,EAAE;IAC9C,OAAOJ,YAAY,cAACrB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;MAACC,mBAAmB,EAAES;IAAsB,CAAE,CAAC,CAAC;EACpF;;EAEA;EACA,OAAO;IAAEb,MAAM;IAAEQ,QAAQ;IAAEE;EAAQ,CAAC;AACtC","ignoreList":[]}
1
+ {"version":3,"file":"render-hook.js","names":["React","_interopRequireWildcard","require","_render","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","renderHook","hookToRender","options","initialProps","renderOptions","result","createRef","TestComponent","hookProps","renderResult","useEffect","current","rerender","componentRerender","unmount","renderInternal","createElement"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import * as React from 'react';\nimport { renderInternal } from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: React.MutableRefObject<Result>;\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = {\n /**\n * The initial props to pass to the hook.\n */\n initialProps?: Props;\n\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n\n /**\n * Set to `false` to disable concurrent rendering.\n * Otherwise `renderHook` will default to concurrent rendering.\n */\n concurrentRoot?: boolean;\n};\n\nexport function renderHook<Result, Props>(\n hookToRender: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): RenderHookResult<Result, Props> {\n const { initialProps, ...renderOptions } = options ?? {};\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({ hookProps }: { hookProps: Props }) {\n const renderResult = hookToRender(hookProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: componentRerender, unmount } = renderInternal(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent hookProps={initialProps} />,\n renderOptions,\n );\n\n function rerender(hookProps: Props) {\n return componentRerender(<TestComponent hookProps={hookProps} />);\n }\n\n return {\n // Result should already be set after the first render effects are run.\n result: result as React.MutableRefObject<Result>,\n rerender,\n unmount,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAA0C,SAAAE,yBAAAC,CAAA,6BAAAC,OA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AAC;EAEvE,SAASC,aAAaA,CAAC;IAAEC;EAAgC,CAAC,EAAE;IAC1D,MAAMC,YAAY,GAAGR,YAAY,CAACO,SAAS,CAAC;IAE5ChC,KAAK,CAACkC,SAAS,CAAC,MAAM;MACpBL,MAAM,CAACM,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,iBAAiB;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAc;EAAA;EAC7D;EACAvC,KAAA,CAAAwC,aAAA,CAACT,aAAa;IAACC,SAAS,EAAEL;EAAa,CAAE,CAAC,EAC1CC,aACF,CAAC;EAED,SAASQ,QAAQA,CAACJ,SAAgB,EAAE;IAClC,OAAOK,iBAAiB,cAACrC,KAAA,CAAAwC,aAAA,CAACT,aAAa;MAACC,SAAS,EAAEA;IAAU,CAAE,CAAC,CAAC;EACnE;EAEA,OAAO;IACL;IACAH,MAAM,EAAEA,MAAwC;IAChDO,QAAQ;IACRE;EACF,CAAC;AACH","ignoreList":[]}
package/build/render.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
1
  import * as React from 'react';
3
- import { DebugOptions } from './helpers/debug';
2
+ import type { ReactTestInstance } from 'react-test-renderer';
3
+ import type { DebugOptions } from './helpers/debug';
4
4
  export interface RenderOptions {
5
5
  /**
6
6
  * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
7
- * reusable custom render functions for common data providers.
7
+ * reusable custom render functions for common data providers.
8
8
  */
9
9
  wrapper?: React.ComponentType<any>;
10
10
  /**
@@ -29,16 +29,16 @@ export default function render<T>(component: React.ReactElement<T>, options?: Re
29
29
  root: ReactTestInstance;
30
30
  UNSAFE_root: ReactTestInstance;
31
31
  UNSAFE_getByProps: (props: {
32
- [key: string]: any;
32
+ [x: string]: unknown;
33
33
  }) => ReactTestInstance;
34
34
  UNSAFE_getAllByProps: (props: {
35
- [key: string]: any;
35
+ [x: string]: unknown;
36
36
  }) => Array<ReactTestInstance>;
37
37
  UNSAFE_queryByProps: (props: {
38
- [key: string]: any;
38
+ [x: string]: unknown;
39
39
  }) => ReactTestInstance | null;
40
40
  UNSAFE_queryAllByProps: (props: {
41
- [key: string]: any;
41
+ [x: string]: unknown;
42
42
  }) => Array<ReactTestInstance>;
43
43
  UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
44
44
  UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
@@ -108,16 +108,16 @@ export declare function renderInternal<T>(component: React.ReactElement<T>, opti
108
108
  root: ReactTestInstance;
109
109
  UNSAFE_root: ReactTestInstance;
110
110
  UNSAFE_getByProps: (props: {
111
- [key: string]: any;
111
+ [x: string]: unknown;
112
112
  }) => ReactTestInstance;
113
113
  UNSAFE_getAllByProps: (props: {
114
- [key: string]: any;
114
+ [x: string]: unknown;
115
115
  }) => Array<ReactTestInstance>;
116
116
  UNSAFE_queryByProps: (props: {
117
- [key: string]: any;
117
+ [x: string]: unknown;
118
118
  }) => ReactTestInstance | null;
119
119
  UNSAFE_queryAllByProps: (props: {
120
- [key: string]: any;
120
+ [x: string]: unknown;
121
121
  }) => Array<ReactTestInstance>;
122
122
  UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
123
123
  UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
@@ -178,4 +178,4 @@ export declare function renderInternal<T>(component: React.ReactElement<T>, opti
178
178
  findByText: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
179
179
  findAllByText: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
180
180
  };
181
- export type DebugFunction = (options?: DebugOptions | string) => void;
181
+ export type DebugFunction = (options?: DebugOptions) => void;
package/build/render.js CHANGED
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = render;
7
7
  exports.renderInternal = renderInternal;
8
- var _react = _interopRequireWildcard(require("react"));
9
- var React = _react;
8
+ var React = _interopRequireWildcard(require("react"));
10
9
  var _act = _interopRequireDefault(require("./act"));
11
10
  var _cleanup = require("./cleanup");
12
11
  var _config = require("./config");
@@ -49,21 +48,20 @@ function renderInternal(component, options) {
49
48
  return buildRenderResult(renderer, wrap);
50
49
  }
51
50
  function renderWithStringValidation(component, options = {}) {
52
- let renderer;
53
51
  const {
54
52
  wrapper: Wrapper,
55
53
  ...testRendererOptions
56
54
  } = options ?? {};
55
+ const wrap = element => /*#__PURE__*/React.createElement(React.Profiler, {
56
+ id: "renderProfiler",
57
+ onRender: handleRender
58
+ }, Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element);
57
59
  const handleRender = (_, phase) => {
58
60
  if (renderer && phase === 'update') {
59
61
  (0, _stringValidation.validateStringsRenderedWithinText)(renderer.toJSON());
60
62
  }
61
63
  };
62
- const wrap = element => /*#__PURE__*/React.createElement(_react.Profiler, {
63
- id: "renderProfiler",
64
- onRender: handleRender
65
- }, Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element);
66
- renderer = (0, _renderAct.renderWithAct)(wrap(component), testRendererOptions);
64
+ const renderer = (0, _renderAct.renderWithAct)(wrap(component), testRendererOptions);
67
65
  (0, _stringValidation.validateStringsRenderedWithinText)(renderer.toJSON());
68
66
  return buildRenderResult(renderer, wrap);
69
67
  }
@@ -83,7 +81,7 @@ function buildRenderResult(renderer, wrap) {
83
81
  rerender: update,
84
82
  // alias for `update`
85
83
  toJSON: renderer.toJSON,
86
- debug: makeDebug(instance, renderer),
84
+ debug: makeDebug(renderer),
87
85
  get root() {
88
86
  return (0, _componentTree.getHostSelves)(instance)[0];
89
87
  },
@@ -108,22 +106,15 @@ function updateWithAct(renderer, wrap) {
108
106
  });
109
107
  };
110
108
  }
111
- function makeDebug(instance, renderer) {
109
+ function makeDebug(renderer) {
112
110
  function debugImpl(options) {
113
111
  const {
114
112
  defaultDebugOptions
115
113
  } = (0, _config.getConfig)();
116
- const debugOptions = typeof options === 'string' ? {
117
- ...defaultDebugOptions,
118
- message: options
119
- } : {
114
+ const debugOptions = {
120
115
  ...defaultDebugOptions,
121
116
  ...options
122
117
  };
123
- if (typeof options === 'string') {
124
- // eslint-disable-next-line no-console
125
- console.warn('Using debug("message") is deprecated and will be removed in future release, please use debug({ message: "message" }) instead.');
126
- }
127
118
  const json = renderer.toJSON();
128
119
  if (json) {
129
120
  return (0, _debug.debug)(json, debugOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["_react","_interopRequireWildcard","require","React","_act","_interopRequireDefault","_cleanup","_config","_componentTree","_debug","_stringValidation","_renderAct","_screen","_within","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","render","component","options","renderInternal","wrapper","Wrapper","concurrentRoot","unstable_validateStringsRenderedWithinText","rest","testRendererOptions","unstable_isConcurrent","getConfig","renderWithStringValidation","wrap","element","createElement","renderer","renderWithAct","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","toJSON","Profiler","id","onRender","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","rerender","debug","makeDebug","getHostSelves","UNSAFE_root","enumerable","Error","setRenderResult","debugImpl","defaultDebugOptions","debugOptions","message","console","warn","json"],"sources":["../src/render.tsx"],"sourcesContent":["import type {\n ReactTestInstance,\n ReactTestRenderer,\n TestRendererOptions,\n} from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport { getHostSelves } from './helpers/component-tree';\nimport { debug, DebugOptions } from './helpers/debug';\nimport { validateStringsRenderedWithinText } from './helpers/string-validation';\nimport { renderWithAct } from './render-act';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n wrapper?: React.ComponentType<any>;\n\n /**\n * Set to `false` to disable concurrent rendering.\n * Otherwise `render` will default to concurrent rendering.\n */\n concurrentRoot?: boolean;\n\n createNodeMock?: (element: React.ReactElement) => unknown;\n unstable_validateStringsRenderedWithinText?: boolean;\n}\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using React Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(component: React.ReactElement<T>, options: RenderOptions = {}) {\n return renderInternal(component, options);\n}\n\nexport function renderInternal<T>(component: React.ReactElement<T>, options?: RenderOptions) {\n const {\n wrapper: Wrapper,\n concurrentRoot,\n unstable_validateStringsRenderedWithinText,\n ...rest\n } = options || {};\n\n const testRendererOptions: TestRendererOptions = {\n ...rest,\n // @ts-expect-error incomplete typing on RTR package\n unstable_isConcurrent: concurrentRoot ?? getConfig().concurrentRoot,\n };\n\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n ...testRendererOptions,\n });\n }\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = renderWithAct(wrap(component), testRendererOptions);\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n options: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {},\n) {\n let renderer: ReactTestRenderer;\n const { wrapper: Wrapper, ...testRendererOptions } = options ?? {};\n\n const handleRender: React.ProfilerOnRenderCallback = (_, phase) => {\n if (renderer && phase === 'update') {\n validateStringsRenderedWithinText(renderer.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n renderer = renderWithAct(wrap(component), testRendererOptions);\n\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element,\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n void act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: makeDebug(instance, renderer),\n get root(): ReactTestInstance {\n return getHostSelves(instance)[0];\n },\n UNSAFE_root: instance,\n };\n\n // Add as non-enumerable property, so that it's safe to enumerate\n // `render` result, e.g. using destructuring rest syntax.\n Object.defineProperty(result, 'container', {\n enumerable: false,\n get() {\n throw new Error(\n \"'container' property has been renamed to 'UNSAFE_root'.\\n\\n\" +\n \"Consider using 'root' property which returns root host element.\",\n );\n },\n });\n\n setRenderResult(result);\n\n return result;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement,\n) {\n return function (component: React.ReactElement) {\n void act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\nexport type DebugFunction = (options?: DebugOptions | string) => void;\n\nfunction makeDebug(instance: ReactTestInstance, renderer: ReactTestRenderer): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message: \"message\" }) instead.',\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debug(json, debugOptions);\n }\n }\n return debugImpl;\n}\n"],"mappings":";;;;;;;AAKA,IAAAA,MAAA,G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AMC,IAAI,GAAGlC,QAAQ,CAACO,MAAM,CAAC,CAAC;IAC9B,IAAI2B,IAAI,EAAE;MACR,OAAO,IAAAb,YAAK,EAACa,IAAI,EAAEJ,YAAY,CAAC;IAClC;EACF;EACA,OAAOF,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","_act","_interopRequireDefault","_cleanup","_config","_componentTree","_debug","_stringValidation","_renderAct","_screen","_within","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","render","component","options","renderInternal","wrapper","Wrapper","concurrentRoot","unstable_validateStringsRenderedWithinText","rest","testRendererOptions","unstable_isConcurrent","getConfig","renderWithStringValidation","wrap","element","createElement","renderer","renderWithAct","buildRenderResult","Profiler","id","onRender","handleRender","_","phase","validateStringsRenderedWithinText","toJSON","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","rerender","debug","makeDebug","getHostSelves","UNSAFE_root","enumerable","Error","setRenderResult","debugImpl","defaultDebugOptions","debugOptions","json"],"sources":["../src/render.tsx"],"sourcesContent":["import * as React from 'react';\nimport type {\n ReactTestInstance,\n ReactTestRenderer,\n TestRendererOptions,\n} from 'react-test-renderer';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport { getHostSelves } from './helpers/component-tree';\nimport type { DebugOptions } from './helpers/debug';\nimport { debug } from './helpers/debug';\nimport { validateStringsRenderedWithinText } from './helpers/string-validation';\nimport { renderWithAct } from './render-act';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n\n /**\n * Set to `false` to disable concurrent rendering.\n * Otherwise `render` will default to concurrent rendering.\n */\n concurrentRoot?: boolean;\n\n createNodeMock?: (element: React.ReactElement) => unknown;\n unstable_validateStringsRenderedWithinText?: boolean;\n}\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using React Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(component: React.ReactElement<T>, options: RenderOptions = {}) {\n return renderInternal(component, options);\n}\n\nexport function renderInternal<T>(component: React.ReactElement<T>, options?: RenderOptions) {\n const {\n wrapper: Wrapper,\n concurrentRoot,\n unstable_validateStringsRenderedWithinText,\n ...rest\n } = options || {};\n\n const testRendererOptions: TestRendererOptions = {\n ...rest,\n // @ts-expect-error incomplete typing on RTR package\n unstable_isConcurrent: concurrentRoot ?? getConfig().concurrentRoot,\n };\n\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n ...testRendererOptions,\n });\n }\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = renderWithAct(wrap(component), testRendererOptions);\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n options: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {},\n) {\n const { wrapper: Wrapper, ...testRendererOptions } = options ?? {};\n\n const wrap = (element: React.ReactElement) => (\n <React.Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </React.Profiler>\n );\n\n const handleRender: React.ProfilerOnRenderCallback = (_, phase) => {\n if (renderer && phase === 'update') {\n validateStringsRenderedWithinText(renderer.toJSON());\n }\n };\n\n const renderer: ReactTestRenderer = renderWithAct(wrap(component), testRendererOptions);\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element,\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n void act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: makeDebug(renderer),\n get root(): ReactTestInstance {\n return getHostSelves(instance)[0];\n },\n UNSAFE_root: instance,\n };\n\n // Add as non-enumerable property, so that it's safe to enumerate\n // `render` result, e.g. using destructuring rest syntax.\n Object.defineProperty(result, 'container', {\n enumerable: false,\n get() {\n throw new Error(\n \"'container' property has been renamed to 'UNSAFE_root'.\\n\\n\" +\n \"Consider using 'root' property which returns root host element.\",\n );\n },\n });\n\n setRenderResult(result);\n\n return result;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement,\n) {\n return function (component: React.ReactElement) {\n void act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\nexport type DebugFunction = (options?: DebugOptions) => void;\n\nfunction makeDebug(renderer: ReactTestRenderer): DebugFunction {\n function debugImpl(options?: DebugOptions) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions = { ...defaultDebugOptions, ...options };\n const json = renderer.toJSON();\n if (json) {\n return debug(json, debugOptions);\n }\n }\n return debugImpl;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAMA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAgD,SAAAE,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,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6D,GAC3D,iEACJ,CAAC;IACH;EACF,CAAC,CAAC;EAEF,IAAAC,uBAAe,EAACT,MAAM,CAAC;EAEvB,OAAOA,MAAM;AACf;AAEA,SAASN,aAAaA,CACpBZ,QAA2B,EAC3BH,IAA8D,EAC9D;EACA,OAAO,UAAUZ,SAA6B,EAAE;IAC9C,KAAK,IAAA+B,YAAG,EAAC,MAAM;MACbhB,QAAQ,CAACW,MAAM,CAACd,IAAI,CAACZ,SAAS,CAAC,CAAC;IAClC,CAAC,CAAC;EACJ,CAAC;AACH;AAIA,SAASqC,SAASA,CAACtB,QAA2B,EAAiB;EAC7D,SAAS4B,SAASA,CAAC1C,OAAsB,EAAE;IACzC,MAAM;MAAE2C;IAAoB,CAAC,GAAG,IAAAlC,iBAAS,EAAC,CAAC;IAC3C,MAAMmC,YAAY,GAAG;MAAE,GAAGD,mBAAmB;MAAE,GAAG3C;IAAQ,CAAC;IAC3D,MAAM6C,IAAI,GAAG/B,QAAQ,CAACU,MAAM,CAAC,CAAC;IAC9B,IAAIqB,IAAI,EAAE;MACR,OAAO,IAAAV,YAAK,EAACU,IAAI,EAAED,YAAY,CAAC;IAClC;EACF;EACA,OAAOF,SAAS;AAClB","ignoreList":[]}
package/build/screen.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RenderResult } from './render';
1
+ import type { RenderResult } from './render';
2
2
  interface Screen extends RenderResult {
3
3
  isDetached?: boolean;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","notImplementedDebug","defaultScreen","isDetached","root","UNSAFE_root","debug","update","unmount","rerender","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","UNSAFE_getByProps","UNSAFE_getAllByProps","UNSAFE_queryByProps","UNSAFE_queryAllByProps","UNSAFE_getByType","UNSAFE_getAllByType","UNSAFE_queryByType","UNSAFE_queryAllByType","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","exports","setRenderResult","renderResult","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` method has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\nconst notImplementedDebug = () => {\n throw new Error(SCREEN_ERROR);\n};\n\ninterface Screen extends RenderResult {\n isDetached?: boolean;\n}\n\nconst defaultScreen: Screen = {\n isDetached: true,\n get root(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n get UNSAFE_root(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplementedDebug,\n update: notImplemented,\n unmount: notImplemented,\n rerender: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n UNSAFE_getByProps: notImplemented,\n UNSAFE_getAllByProps: notImplemented,\n UNSAFE_queryByProps: notImplemented,\n UNSAFE_queryAllByProps: notImplemented,\n UNSAFE_getByType: notImplemented,\n UNSAFE_getAllByType: notImplemented,\n UNSAFE_queryByType: notImplemented,\n UNSAFE_queryAllByType: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: Screen = defaultScreen;\n\nexport function setRenderResult(renderResult: RenderResult) {\n screen = renderResult;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"mappings":";;;;;;;;AAGA,MAAMA,YAAY,GAAG,qCAAqC;AAE1D,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAC3B,MAAM,IAAIC,KAAK,CAAC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A,CAACC,YAA0B,EAAE;EAC1DF,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAGG,YAAY;AACvB;AAEO,SAASC,iBAAiBA,CAAA,EAAG;EAClCH,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAGvE,aAAa;AACxB","ignoreList":[]}
1
+ {"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","notImplementedDebug","defaultScreen","isDetached","root","UNSAFE_root","debug","update","unmount","rerender","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","UNSAFE_getByProps","UNSAFE_getAllByProps","UNSAFE_queryByProps","UNSAFE_queryAllByProps","UNSAFE_getByType","UNSAFE_getAllByType","UNSAFE_queryByType","UNSAFE_queryAllByType","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","exports","setRenderResult","renderResult","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport type { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` method has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\nconst notImplementedDebug = () => {\n throw new Error(SCREEN_ERROR);\n};\n\ninterface Screen extends RenderResult {\n isDetached?: boolean;\n}\n\nconst defaultScreen: Screen = {\n isDetached: true,\n get root(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n get UNSAFE_root(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplementedDebug,\n update: notImplemented,\n unmount: notImplemented,\n rerender: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n UNSAFE_getByProps: notImplemented,\n UNSAFE_getAllByProps: notImplemented,\n UNSAFE_queryByProps: notImplemented,\n UNSAFE_queryAllByProps: notImplemented,\n UNSAFE_getByType: notImplemented,\n UNSAFE_getAllByType: notImplemented,\n UNSAFE_queryByType: notImplemented,\n UNSAFE_queryAllByType: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: Screen = defaultScreen;\n\nexport function setRenderResult(renderResult: RenderResult) {\n screen = renderResult;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"mappings":";;;;;;;;AAGA,MAAMA,YAAY,GAAG,qCAAqC;AAE1D,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAC3B,MAAM,IAAIC,KAAK,CAACF,YAAY,CAAC;AAC/B,CAAC;AAED,MAAMG,mBAAmB,GAAGA,CAAA,KAAM;EAChC,MAAM,IAAID,KAAK,CAACF,YAAY,CAAC;AAC/B,CAAC;AAMD,MAAMI,aAAqB,GAAG;EAC5BC,UAAU,EAAE,IAAI;EAChB,IAAIC,IAAIA,CAAA,EAAsB;IAC5B,MAAM,IAAIJ,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACD,IAAIO,WAAWA,CAAA,EAAsB;IACnC,MAAM,IAAIL,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACDQ,KAAK,EAAEL,mBAAmB;EAC1BM,MAAM,EAAER,cAAc;EACtBS,OAAO,EAAET,cAAc;EACvBU,QAAQ,EAAEV,cAAc;EACxBW,MAAM,EAAEX,cAAc;EACtBY,cAAc,EAAEZ,cAAc;EAC9Ba,iBAAiB,EAAEb,cAAc;EACjCc,gBAAgB,EAAEd,cAAc;EAChCe,mBAAmB,EAAEf,cAAc;EACnCgB,eAAe,EAAEhB,cAAc;EAC/BiB,kBAAkB,EAAEjB,cAAc;EAClCkB,aAAa,EAAElB,cAAc;EAC7BmB,gBA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