@testing-library/react-native 13.0.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 -2
  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 +8 -7
  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":"dispatch-event.js","names":["_act","_interopRequireDefault","require","_componentTree","e","__esModule","default","dispatchEvent","element","eventName","event","isElementMounted","handler","getEventHandler","act","handleName","getEventHandlerName","handle","props","undefined","charAt","toUpperCase","slice"],"sources":["../../../src/user-event/utils/dispatch-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from '../../act';\nimport { isElementMounted } from '../../helpers/component-tree';\n\n/**\n * Basic dispatch event function used by User Event module.\n *\n * @param element element trigger event on\n * @param eventName name of the event\n * @param event event payload(s)\n */\nexport function dispatchEvent(element: ReactTestInstance, eventName: string, ...event: unknown[]) {\n if (!isElementMounted(element)) {\n return;\n }\n\n const handler = getEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n // This will be called synchronously.\n void act(() => {\n handler(...event);\n });\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const handleName = getEventHandlerName(eventName);\n const handle = element.props[handleName] as unknown;\n if (typeof handle !== 'function') {\n return undefined;\n }\n\n return handle;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAAgE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAACC,OAA0B,EAAEC,SAAiB,EAAE,GAAGC,KAAgB,EAAE;EAChG,IAAI,CAAC,IAAAC,+BAAgB,EAACH,OAAO,CAAC,EAAE;IAC9B;EACF;EAEA,MAAMI,OAAO,GAAGC,eAAe,CAACL,OAAO,EAAEC,SAAS,CAAC;EACnD,IAAI,CAACG,OAAO,EAAE;IACZ;EACF;;EAEA;EACA,KAAK,IAAAE,YAAG,EAAC,MAAM;IACbF,OAAO,CAAC,GAAGF,KAAK,CAAC;EACnB,CAAC,CAAC;AACJ;AAEA,SAASG,eAAeA,CAACL,OAA0B,EAAEC,SAAiB,EAAE;EACtE,MAAMM,UAAU,GAAGC,mBAAmB,CAACP,SAAS,CAAC;EACjD,MAAMQ,MAAM,GAAGT,OAAO,CAACU,KAAK,CAACH,UAAU,CAAY;EACnD,IAAI,OAAOE,MAAM,KAAK,UAAU,EAAE;IAChC,OAAOE,SAAS;EAClB;EAEA,OAAOF,MAAM;AACf;AAEA,SAASD,mBAAmBA,CAACP,SAAiB,EAAE;EAC9C,OAAO,KAAKA,SAAS,CAACW,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGZ,SAAS,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;AACtE","ignoreList":[]}
1
+ {"version":3,"file":"dispatch-event.js","names":["_act","_interopRequireDefault","require","_componentTree","e","__esModule","default","dispatchEvent","element","eventName","event","isElementMounted","handler","getEventHandler","act","handleName","getEventHandlerName","handle","props","undefined","charAt","toUpperCase","slice"],"sources":["../../../src/user-event/utils/dispatch-event.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport act from '../../act';\nimport { isElementMounted } from '../../helpers/component-tree';\n\n/**\n * Basic dispatch event function used by User Event module.\n *\n * @param element element trigger event on\n * @param eventName name of the event\n * @param event event payload(s)\n */\nexport function dispatchEvent(element: ReactTestInstance, eventName: string, ...event: unknown[]) {\n if (!isElementMounted(element)) {\n return;\n }\n\n const handler = getEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n // This will be called synchronously.\n void act(() => {\n handler(...event);\n });\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const handleName = getEventHandlerName(eventName);\n const handle = element.props[handleName] as unknown;\n if (typeof handle !== 'function') {\n return undefined;\n }\n\n return handle;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAAgE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAACC,OAA0B,EAAEC,SAAiB,EAAE,GAAGC,KAAgB,EAAE;EAChG,IAAI,CAAC,IAAAC,+BAAgB,EAACH,OAAO,CAAC,EAAE;IAC9B;EACF;EAEA,MAAMI,OAAO,GAAGC,eAAe,CAACL,OAAO,EAAEC,SAAS,CAAC;EACnD,IAAI,CAACG,OAAO,EAAE;IACZ;EACF;;EAEA;EACA,KAAK,IAAAE,YAAG,EAAC,MAAM;IACbF,OAAO,CAAC,GAAGF,KAAK,CAAC;EACnB,CAAC,CAAC;AACJ;AAEA,SAASG,eAAeA,CAACL,OAA0B,EAAEC,SAAiB,EAAE;EACtE,MAAMM,UAAU,GAAGC,mBAAmB,CAACP,SAAS,CAAC;EACjD,MAAMQ,MAAM,GAAGT,OAAO,CAACU,KAAK,CAACH,UAAU,CAAY;EACnD,IAAI,OAAOE,MAAM,KAAK,UAAU,EAAE;IAChC,OAAOE,SAAS;EAClB;EAEA,OAAOF,MAAM;AACf;AAEA,SAASD,mBAAmBA,CAACP,SAAiB,EAAE;EAC9C,OAAO,KAAKA,SAAS,CAACW,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGZ,SAAS,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;AACtE","ignoreList":[]}
@@ -1,2 +1,6 @@
1
- import { UserEventConfig } from '../setup';
2
- export declare function wait(config: UserEventConfig, durationInMs?: number): Promise<[void, void]> | undefined;
1
+ type WaitConfig = {
2
+ delay?: number;
3
+ advanceTimers: (delay: number) => Promise<void> | void;
4
+ };
5
+ export declare function wait(config: WaitConfig, durationInMs?: number): Promise<[void, void]> | undefined;
6
+ export {};
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.wait = wait;
7
7
  function wait(config, durationInMs) {
8
8
  const delay = durationInMs ?? config.delay;
9
- if (typeof delay !== 'number') {
9
+ if (typeof delay !== 'number' || delay == null) {
10
10
  return;
11
11
  }
12
12
  return Promise.all([new Promise(resolve => globalThis.setTimeout(() => resolve(), delay)), config.advanceTimers(delay)]);
@@ -1 +1 @@
1
- {"version":3,"file":"wait.js","names":["wait","config","durationInMs","delay","Promise","all","resolve","globalThis","setTimeout","advanceTimers"],"sources":["../../../src/user-event/utils/wait.ts"],"sourcesContent":["import { UserEventConfig } from '../setup';\n\nexport function wait(config: UserEventConfig, durationInMs?: number) {\n const delay = durationInMs ?? config.delay;\n if (typeof delay !== 'number') {\n return;\n }\n\n return Promise.all([\n new Promise<void>((resolve) => globalThis.setTimeout(() => resolve(), delay)),\n config.advanceTimers(delay),\n ]);\n}\n"],"mappings":";;;;;;AAEO,SAASA,IAAIA,CAACC,MAAuB,EAAEC,YAAqB,EAAE;EACnE,MAAMC,KAAK,GAAGD,YAAY,IAAID,MAAM,CAACE,KAAK;EAC1C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B;EACF;EAEA,OAAOC,OAAO,CAACC,GAAG,CAAC,CACjB,IAAID,OAAO,CAAQE,OAAO,IAAKC,UAAU,CAACC,UAAU,CAAC,MAAMF,OAAO,CAAC,CAAC,EAAEH,KAAK,CAAC,CAAC,EAC7EF,MAAM,CAACQ,aAAa,CAACN,KAAK,CAAC,CAC5B,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"wait.js","names":["wait","config","durationInMs","delay","Promise","all","resolve","globalThis","setTimeout","advanceTimers"],"sources":["../../../src/user-event/utils/wait.ts"],"sourcesContent":["type WaitConfig = {\n delay?: number;\n advanceTimers: (delay: number) => Promise<void> | void;\n};\n\nexport function wait(config: WaitConfig, durationInMs?: number) {\n const delay = durationInMs ?? config.delay;\n if (typeof delay !== 'number' || delay == null) {\n return;\n }\n\n return Promise.all([\n new Promise<void>((resolve) => globalThis.setTimeout(() => resolve(), delay)),\n config.advanceTimers(delay),\n ]);\n}\n"],"mappings":";;;;;;AAKO,SAASA,IAAIA,CAACC,MAAkB,EAAEC,YAAqB,EAAE;EAC9D,MAAMC,KAAK,GAAGD,YAAY,IAAID,MAAM,CAACE,KAAK;EAC1C,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,IAAI,IAAI,EAAE;IAC9C;EACF;EAEA,OAAOC,OAAO,CAACC,GAAG,CAAC,CACjB,IAAID,OAAO,CAAQE,OAAO,IAAKC,UAAU,CAACC,UAAU,CAAC,MAAMF,OAAO,CAAC,CAAC,EAAEH,KAAK,CAAC,CAAC,EAC7EF,MAAM,CAACQ,aAAa,CAACN,KAAK,CAAC,CAC5B,CAAC;AACJ","ignoreList":[]}
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = waitForElementToBeRemoved;
7
- var _waitFor = _interopRequireDefault(require("./wait-for"));
8
7
  var _errors = require("./helpers/errors");
8
+ var _waitFor = _interopRequireDefault(require("./wait-for"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
10
  function isRemoved(result) {
11
11
  return !result || Array.isArray(result) && !result.length;
@@ -1 +1 @@
1
- {"version":3,"file":"wait-for-element-to-be-removed.js","names":["_waitFor","_interopRequireDefault","require","_errors","e","__esModule","default","isRemoved","result","Array","isArray","length","waitForElementToBeRemoved","expectation","options","timeoutError","ErrorWithStack","initialElements","waitFor"],"sources":["../src/wait-for-element-to-be-removed.ts"],"sourcesContent":["import waitFor from './wait-for';\nimport type { WaitForOptions } from './wait-for';\nimport { ErrorWithStack } from './helpers/errors';\n\nfunction isRemoved<T>(result: T): boolean {\n return !result || (Array.isArray(result) && !result.length);\n}\n\nexport default async function waitForElementToBeRemoved<T>(\n expectation: () => T,\n options?: WaitForOptions,\n): Promise<T> {\n // Created here so we get a nice stacktrace\n const timeoutError = new ErrorWithStack(\n 'Timed out in waitForElementToBeRemoved.',\n waitForElementToBeRemoved,\n );\n\n // Elements have to be present initally and then removed.\n const initialElements = expectation();\n if (isRemoved(initialElements)) {\n throw new ErrorWithStack(\n 'The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.',\n waitForElementToBeRemoved,\n );\n }\n\n return await waitFor(() => {\n let result;\n try {\n result = expectation();\n } catch {\n return initialElements;\n }\n\n if (!isRemoved(result)) {\n throw timeoutError;\n }\n\n return initialElements;\n }, options);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAkD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElD,SAASG,SAASA,CAAIC,MAAS,EAAW;EACxC,OAAO,CAACA,MAAM,IAAKC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAI,CAACA,MAAM,CAACG,MAAO;AAC7D;AAEe,eAAeC,yBAAyBA,CACrDC,WAAoB,EACpBC,OAAwB,EACZ;EACZ;EACA,MAAMC,YAAY,GAAG,IAAIC,sBAAc,CACrC,yCAAyC,EACzCJ,yBACF,CAAC;;EAED;EACA,MAAMK,eAAe,GAAGJ,WAAW,CAAC,CAAC;EACrC,IAAIN,SAAS,CAACU,eAAe,CAAC,EAAE;IAC9B,MAAM,IAAID,sBAAc,CACtB,oKAAoK,EACpKJ,yBACF,CAAC;EACH;EAEA,OAAO,MAAM,IAAAM,gBAAO,EAAC,MAAM;IACzB,IAAIV,MAAM;IACV,IAAI;MACFA,MAAM,GAAGK,WAAW,CAAC,CAAC;IACxB,CAAC,CAAC,MAAM;MACN,OAAOI,eAAe;IACxB;IAEA,IAAI,CAACV,SAAS,CAACC,MAAM,CAAC,EAAE;MACtB,MAAMO,YAAY;IACpB;IAEA,OAAOE,eAAe;EACxB,CAAC,EAAEH,OAAO,CAAC;AACb","ignoreList":[]}
1
+ {"version":3,"file":"wait-for-element-to-be-removed.js","names":["_errors","require","_waitFor","_interopRequireDefault","e","__esModule","default","isRemoved","result","Array","isArray","length","waitForElementToBeRemoved","expectation","options","timeoutError","ErrorWithStack","initialElements","waitFor"],"sources":["../src/wait-for-element-to-be-removed.ts"],"sourcesContent":["import { ErrorWithStack } from './helpers/errors';\nimport type { WaitForOptions } from './wait-for';\nimport waitFor from './wait-for';\n\nfunction isRemoved<T>(result: T): boolean {\n return !result || (Array.isArray(result) && !result.length);\n}\n\nexport default async function waitForElementToBeRemoved<T>(\n expectation: () => T,\n options?: WaitForOptions,\n): Promise<T> {\n // Created here so we get a nice stacktrace\n const timeoutError = new ErrorWithStack(\n 'Timed out in waitForElementToBeRemoved.',\n waitForElementToBeRemoved,\n );\n\n // Elements have to be present initally and then removed.\n const initialElements = expectation();\n if (isRemoved(initialElements)) {\n throw new ErrorWithStack(\n 'The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.',\n waitForElementToBeRemoved,\n );\n }\n\n return await waitFor(() => {\n let result;\n try {\n result = expectation();\n } catch {\n return initialElements;\n }\n\n if (!isRemoved(result)) {\n throw timeoutError;\n }\n\n return initialElements;\n }, options);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAiC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjC,SAASG,SAASA,CAAIC,MAAS,EAAW;EACxC,OAAO,CAACA,MAAM,IAAKC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAI,CAACA,MAAM,CAACG,MAAO;AAC7D;AAEe,eAAeC,yBAAyBA,CACrDC,WAAoB,EACpBC,OAAwB,EACZ;EACZ;EACA,MAAMC,YAAY,GAAG,IAAIC,sBAAc,CACrC,yCAAyC,EACzCJ,yBACF,CAAC;;EAED;EACA,MAAMK,eAAe,GAAGJ,WAAW,CAAC,CAAC;EACrC,IAAIN,SAAS,CAACU,eAAe,CAAC,EAAE;IAC9B,MAAM,IAAID,sBAAc,CACtB,oKAAoK,EACpKJ,yBACF,CAAC;EACH;EAEA,OAAO,MAAM,IAAAM,gBAAO,EAAC,MAAM;IACzB,IAAIV,MAAM;IACV,IAAI;MACFA,MAAM,GAAGK,WAAW,CAAC,CAAC;IACxB,CAAC,CAAC,MAAM;MACN,OAAOI,eAAe;IACxB;IAEA,IAAI,CAACV,SAAS,CAACC,MAAM,CAAC,EAAE;MACtB,MAAMO,YAAY;IACpB;IAEA,OAAOE,eAAe;EACxB,CAAC,EAAEH,OAAO,CAAC;AACb","ignoreList":[]}
package/build/wait-for.js CHANGED
@@ -35,7 +35,6 @@ function waitForInternal(expectation, {
35
35
  // infinite loop. However, eslint isn't smart enough to know that we're
36
36
  // setting finished inside `onDone` which will be called when we're done
37
37
  // waiting or when we've timed out.
38
- // eslint-disable-next-line no-unmodified-loop-condition
39
38
  let fakeTimeRemaining = timeout;
40
39
  while (!finished) {
41
40
  if (!(0, _timers.jestFakeTimersAreEnabled)()) {
@@ -72,7 +71,6 @@ function waitForInternal(expectation, {
72
71
  // to resolve before continuing. We don't need to take advantage
73
72
  // of parallelization so we're fine.
74
73
  // https://stackoverflow.com/a/59243586/971592
75
- // eslint-disable-next-line no-await-in-loop
76
74
  await (0, _flushMicroTasks.flushMicroTasks)();
77
75
  }
78
76
  } else {
@@ -110,8 +108,7 @@ function waitForInternal(expectation, {
110
108
  try {
111
109
  const result = expectation();
112
110
 
113
- // @ts-ignore result can be a promise
114
- // eslint-disable-next-line promise/prefer-await-to-then
111
+ // @ts-expect-error result can be a promise
115
112
  if (typeof result?.then === 'function') {
116
113
  const promiseResult = result;
117
114
  promiseStatus = 'pending';
@@ -1 +1 @@
1
- {"version":3,"file":"wait-for.js","names":["_config","require","_flushMicroTasks","_errors","_timers","_wrapAsync","DEFAULT_INTERVAL","waitForInternal","expectation","timeout","getConfig","asyncUtilTimeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","usingFakeTimers","jestFakeTimersAreEnabled","checkExpectation","fakeTimeRemaining","error","Error","copyStackTrace","handleTimeout","jest","advanceTimersByTime","flushMicroTasks","setTimeout","setInterval","checkRealTimersCallback","onDone","done","clearTimeout","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","String","waitFor","options","ErrorWithStack","optionsWithStackTrace","wrapAsync"],"sources":["../src/wait-for.ts"],"sourcesContent":["/* globals jest */\nimport { getConfig } from './config';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport { setTimeout, clearTimeout, jestFakeTimersAreEnabled } from './helpers/timers';\nimport { wrapAsync } from './helpers/wrap-async';\n\nconst DEFAULT_INTERVAL = 50;\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n stackTraceError?: ErrorWithStack;\n onTimeout?: (error: Error) => Error;\n};\n\nfunction waitForInternal<T>(\n expectation: () => T,\n {\n timeout = getConfig().asyncUtilTimeout,\n interval = DEFAULT_INTERVAL,\n stackTraceError,\n onTimeout,\n }: WaitForOptions,\n): Promise<T> {\n if (typeof expectation !== 'function') {\n throw new TypeError('Received `expectation` arg must be a function');\n }\n\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n let lastError: unknown, intervalId: ReturnType<typeof setTimeout>;\n let finished = false;\n let promiseStatus = 'idle';\n\n let overallTimeoutTimer: NodeJS.Timeout | null = null;\n\n const usingFakeTimers = jestFakeTimersAreEnabled();\n\n if (usingFakeTimers) {\n checkExpectation();\n // this is a dangerous rule to disable because it could lead to an\n // infinite loop. However, eslint isn't smart enough to know that we're\n // setting finished inside `onDone` which will be called when we're done\n // waiting or when we've timed out.\n // eslint-disable-next-line no-unmodified-loop-condition\n let fakeTimeRemaining = timeout;\n while (!finished) {\n if (!jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n reject(error);\n return;\n }\n\n // when fake timers are used we want to simulate the interval time passing\n if (fakeTimeRemaining <= 0) {\n handleTimeout();\n return;\n } else {\n fakeTimeRemaining -= interval;\n }\n\n // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's\n // possible that could make this loop go on forever if someone is using\n // third party code that's setting up recursive timers so rapidly that\n // the user's timer's don't get a chance to resolve. So we'll advance\n // by an interval instead. (We have a test for this case).\n jest.advanceTimersByTime(interval);\n\n // It's really important that checkExpectation is run *before* we flush\n // in-flight promises. To be honest, I'm not sure why, and I can't quite\n // think of a way to reproduce the problem in a test, but I spent\n // an entire day banging my head against a wall on this.\n checkExpectation();\n\n // In this rare case, we *need* to wait for in-flight promises\n // to resolve before continuing. We don't need to take advantage\n // of parallelization so we're fine.\n // https://stackoverflow.com/a/59243586/971592\n // eslint-disable-next-line no-await-in-loop\n await flushMicroTasks();\n }\n } else {\n overallTimeoutTimer = setTimeout(handleTimeout, timeout);\n intervalId = setInterval(checkRealTimersCallback, interval);\n checkExpectation();\n }\n\n function onDone(done: { type: 'result'; result: T } | { type: 'error'; error: unknown }) {\n finished = true;\n if (overallTimeoutTimer) {\n clearTimeout(overallTimeoutTimer);\n }\n\n if (!usingFakeTimers) {\n clearInterval(intervalId);\n }\n\n if (done.type === 'error') {\n reject(done.error);\n } else {\n resolve(done.result);\n }\n }\n\n function checkRealTimersCallback() {\n if (jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n return reject(error);\n } else {\n return checkExpectation();\n }\n }\n\n function checkExpectation() {\n if (promiseStatus === 'pending') return;\n try {\n const result = expectation();\n\n // @ts-ignore result can be a promise\n // eslint-disable-next-line promise/prefer-await-to-then\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as any;\n promiseStatus = 'pending';\n // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then\n promiseResult.then(\n (resolvedValue) => {\n promiseStatus = 'resolved';\n onDone({ type: 'result', result: resolvedValue });\n return;\n },\n (rejectedValue) => {\n promiseStatus = 'rejected';\n lastError = rejectedValue;\n return;\n },\n );\n } else {\n onDone({ type: 'result', result: result });\n }\n // If `callback` throws, wait for the next mutation, interval, or timeout.\n } catch (error) {\n // Save the most recent callback error to reject the promise with it in the event of a timeout\n lastError = error;\n }\n }\n\n function handleTimeout() {\n let error: Error;\n if (lastError) {\n if (lastError instanceof Error) {\n error = lastError;\n } else {\n error = new Error(String(lastError));\n }\n\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n } else {\n error = new Error('Timed out in waitFor.');\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n }\n if (typeof onTimeout === 'function') {\n const result = onTimeout(error);\n if (result) {\n error = result;\n }\n }\n onDone({ type: 'error', error });\n }\n });\n}\n\nexport default function waitFor<T>(expectation: () => T, options?: WaitForOptions): Promise<T> {\n // Being able to display a useful stack trace requires generating it before doing anything async\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', waitFor);\n const optionsWithStackTrace = { stackTraceError, ...options };\n\n return wrapAsync(() => waitForInternal(expectation, optionsWithStackTrace));\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AALA;;AAOA,MAAMK,gBAAgB,GAAG,EAAE;AAS3B,SAASC,eAAeA,CACtBC,WAAoB,EACpB;EACEC,OAAO,GAAG,IAAAC,iBAAS,EAAC,CAAC,CAACC,gBAAgB;EACtCC,QAAQ,GAAGN,gBAAgB;EAC3BO,eAAe;EACfC;AACc,CAAC,EACL;EACZ,IAAI,OAAON,WAAW,KAAK,UAAU,EAAE;IACrC,MAAM,IAAIO,SAAS,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","_errors","_timers","_wrapAsync","DEFAULT_INTERVAL","waitForInternal","expectation","timeout","getConfig","asyncUtilTimeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","usingFakeTimers","jestFakeTimersAreEnabled","checkExpectation","fakeTimeRemaining","error","Error","copyStackTrace","handleTimeout","jest","advanceTimersByTime","flushMicroTasks","setTimeout","setInterval","checkRealTimersCallback","onDone","done","clearTimeout","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","String","waitFor","options","ErrorWithStack","optionsWithStackTrace","wrapAsync"],"sources":["../src/wait-for.ts"],"sourcesContent":["/* globals jest */\nimport { getConfig } from './config';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { copyStackTrace, ErrorWithStack } from './helpers/errors';\nimport { clearTimeout, jestFakeTimersAreEnabled, setTimeout } from './helpers/timers';\nimport { wrapAsync } from './helpers/wrap-async';\n\nconst DEFAULT_INTERVAL = 50;\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n stackTraceError?: ErrorWithStack;\n onTimeout?: (error: Error) => Error;\n};\n\nfunction waitForInternal<T>(\n expectation: () => T,\n {\n timeout = getConfig().asyncUtilTimeout,\n interval = DEFAULT_INTERVAL,\n stackTraceError,\n onTimeout,\n }: WaitForOptions,\n): Promise<T> {\n if (typeof expectation !== 'function') {\n throw new TypeError('Received `expectation` arg must be a function');\n }\n\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n let lastError: unknown, intervalId: ReturnType<typeof setTimeout>;\n let finished = false;\n let promiseStatus = 'idle';\n\n let overallTimeoutTimer: NodeJS.Timeout | null = null;\n\n const usingFakeTimers = jestFakeTimersAreEnabled();\n\n if (usingFakeTimers) {\n checkExpectation();\n // this is a dangerous rule to disable because it could lead to an\n // infinite loop. However, eslint isn't smart enough to know that we're\n // setting finished inside `onDone` which will be called when we're done\n // waiting or when we've timed out.\n let fakeTimeRemaining = timeout;\n while (!finished) {\n if (!jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n reject(error);\n return;\n }\n\n // when fake timers are used we want to simulate the interval time passing\n if (fakeTimeRemaining <= 0) {\n handleTimeout();\n return;\n } else {\n fakeTimeRemaining -= interval;\n }\n\n // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's\n // possible that could make this loop go on forever if someone is using\n // third party code that's setting up recursive timers so rapidly that\n // the user's timer's don't get a chance to resolve. So we'll advance\n // by an interval instead. (We have a test for this case).\n jest.advanceTimersByTime(interval);\n\n // It's really important that checkExpectation is run *before* we flush\n // in-flight promises. To be honest, I'm not sure why, and I can't quite\n // think of a way to reproduce the problem in a test, but I spent\n // an entire day banging my head against a wall on this.\n checkExpectation();\n\n // In this rare case, we *need* to wait for in-flight promises\n // to resolve before continuing. We don't need to take advantage\n // of parallelization so we're fine.\n // https://stackoverflow.com/a/59243586/971592\n await flushMicroTasks();\n }\n } else {\n overallTimeoutTimer = setTimeout(handleTimeout, timeout);\n intervalId = setInterval(checkRealTimersCallback, interval);\n checkExpectation();\n }\n\n function onDone(done: { type: 'result'; result: T } | { type: 'error'; error: unknown }) {\n finished = true;\n if (overallTimeoutTimer) {\n clearTimeout(overallTimeoutTimer);\n }\n\n if (!usingFakeTimers) {\n clearInterval(intervalId);\n }\n\n if (done.type === 'error') {\n reject(done.error);\n } else {\n resolve(done.result);\n }\n }\n\n function checkRealTimersCallback() {\n if (jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n return reject(error);\n } else {\n return checkExpectation();\n }\n }\n\n function checkExpectation() {\n if (promiseStatus === 'pending') return;\n try {\n const result = expectation();\n\n // @ts-expect-error result can be a promise\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as unknown as Promise<T>;\n promiseStatus = 'pending';\n // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then\n promiseResult.then(\n (resolvedValue) => {\n promiseStatus = 'resolved';\n onDone({ type: 'result', result: resolvedValue });\n return;\n },\n (rejectedValue) => {\n promiseStatus = 'rejected';\n lastError = rejectedValue;\n return;\n },\n );\n } else {\n onDone({ type: 'result', result: result });\n }\n // If `callback` throws, wait for the next mutation, interval, or timeout.\n } catch (error) {\n // Save the most recent callback error to reject the promise with it in the event of a timeout\n lastError = error;\n }\n }\n\n function handleTimeout() {\n let error: Error;\n if (lastError) {\n if (lastError instanceof Error) {\n error = lastError;\n } else {\n error = new Error(String(lastError));\n }\n\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n } else {\n error = new Error('Timed out in waitFor.');\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n }\n if (typeof onTimeout === 'function') {\n const result = onTimeout(error);\n if (result) {\n error = result;\n }\n }\n onDone({ type: 'error', error });\n }\n });\n}\n\nexport default function waitFor<T>(expectation: () => T, options?: WaitForOptions): Promise<T> {\n // Being able to display a useful stack trace requires generating it before doing anything async\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', waitFor);\n const optionsWithStackTrace = { stackTraceError, ...options };\n\n return wrapAsync(() => waitForInternal(expectation, optionsWithStackTrace));\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AALA;;AAOA,MAAMK,gBAAgB,GAAG,EAAE;AAS3B,SAASC,eAAeA,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;IAAEvC,eAAe;IAAE,GAAGqC;EAAQ,CAAC;EAE7D,OAAO,IAAAG,oBAAS,EAAC,MAAM9C,eAAe,CAACC,WAAW,EAAE4C,qBAAqB,CAAC,CAAC;AAC7E","ignoreList":[]}
package/build/within.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
2
  export declare function within(instance: ReactTestInstance): {
3
3
  UNSAFE_getByProps: (props: {
4
- [key: string]: any;
4
+ [x: string]: unknown;
5
5
  }) => ReactTestInstance;
6
6
  UNSAFE_getAllByProps: (props: {
7
- [key: string]: any;
7
+ [x: string]: unknown;
8
8
  }) => Array<ReactTestInstance>;
9
9
  UNSAFE_queryByProps: (props: {
10
- [key: string]: any;
10
+ [x: string]: unknown;
11
11
  }) => ReactTestInstance | null;
12
12
  UNSAFE_queryAllByProps: (props: {
13
- [key: string]: any;
13
+ [x: string]: unknown;
14
14
  }) => Array<ReactTestInstance>;
15
15
  UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
16
16
  UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
package/build/within.js CHANGED
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getQueriesForElement = void 0;
7
7
  exports.within = within;
8
- var _text = require("./queries/text");
9
- var _testId = require("./queries/test-id");
10
8
  var _displayValue = require("./queries/display-value");
11
- var _placeholderText = require("./queries/placeholder-text");
12
- var _labelText = require("./queries/label-text");
13
9
  var _hintText = require("./queries/hint-text");
10
+ var _labelText = require("./queries/label-text");
11
+ var _placeholderText = require("./queries/placeholder-text");
14
12
  var _role = require("./queries/role");
15
- var _unsafeType = require("./queries/unsafe-type");
13
+ var _testId = require("./queries/test-id");
14
+ var _text = require("./queries/text");
16
15
  var _unsafeProps = require("./queries/unsafe-props");
16
+ var _unsafeType = require("./queries/unsafe-type");
17
17
  function within(instance) {
18
18
  return {
19
19
  ...(0, _text.bindByTextQueries)(instance),
@@ -1 +1 @@
1
- {"version":3,"file":"within.js","names":["_text","require","_testId","_displayValue","_placeholderText","_labelText","_hintText","_role","_unsafeType","_unsafeProps","within","instance","bindByTextQueries","bindByTestIdQueries","bindByDisplayValueQueries","bindByPlaceholderTextQueries","bindByLabelTextQueries","bindByHintTextQueries","bindByRoleQueries","bindUnsafeByTypeQueries","bindUnsafeByPropsQueries","getQueriesForElement","exports"],"sources":["../src/within.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { bindByTextQueries } from './queries/text';\nimport { bindByTestIdQueries } from './queries/test-id';\nimport { bindByDisplayValueQueries } from './queries/display-value';\nimport { bindByPlaceholderTextQueries } from './queries/placeholder-text';\nimport { bindByLabelTextQueries } from './queries/label-text';\nimport { bindByHintTextQueries } from './queries/hint-text';\nimport { bindByRoleQueries } from './queries/role';\nimport { bindUnsafeByTypeQueries } from './queries/unsafe-type';\nimport { bindUnsafeByPropsQueries } from './queries/unsafe-props';\n\nexport function within(instance: ReactTestInstance) {\n return {\n ...bindByTextQueries(instance),\n ...bindByTestIdQueries(instance),\n ...bindByDisplayValueQueries(instance),\n ...bindByPlaceholderTextQueries(instance),\n ...bindByLabelTextQueries(instance),\n ...bindByHintTextQueries(instance),\n ...bindByRoleQueries(instance),\n ...bindUnsafeByTypeQueries(instance),\n ...bindUnsafeByPropsQueries(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"mappings":";;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEO,SAASS,MAAMA,CAACC,QAA2B,EAAE;EAClD,OAAO;IACL,GAAG,IAAAC,uBAAiB,EAACD,QAAQ,CAAC;IAC9B,GAAG,IAAAE,2BAAmB,EAACF,QAAQ,CAAC;IAChC,GAAG,IAAAG,uCAAyB,EAACH,QAAQ,CAAC;IACtC,GAAG,IAAAI,6CAA4B,EAACJ,QAAQ,CAAC;IACzC,GAAG,IAAAK,iCAAsB,EAACL,QAAQ,CAAC;IACnC,GAAG,IAAAM,+BAAqB,EAACN,QAAQ,CAAC;IAClC,GAAG,IAAAO,uBAAiB,EAACP,QAAQ,CAAC;IAC9B,GAAG,IAAAQ,mCAAuB,EAACR,QAAQ,CAAC;IACpC,GAAG,IAAAS,qCAAwB,EAACT,QAAQ;EACtC,CAAC;AACH;AAEO,MAAMU,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGX,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"within.js","names":["_displayValue","require","_hintText","_labelText","_placeholderText","_role","_testId","_text","_unsafeProps","_unsafeType","within","instance","bindByTextQueries","bindByTestIdQueries","bindByDisplayValueQueries","bindByPlaceholderTextQueries","bindByLabelTextQueries","bindByHintTextQueries","bindByRoleQueries","bindUnsafeByTypeQueries","bindUnsafeByPropsQueries","getQueriesForElement","exports"],"sources":["../src/within.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { bindByDisplayValueQueries } from './queries/display-value';\nimport { bindByHintTextQueries } from './queries/hint-text';\nimport { bindByLabelTextQueries } from './queries/label-text';\nimport { bindByPlaceholderTextQueries } from './queries/placeholder-text';\nimport { bindByRoleQueries } from './queries/role';\nimport { bindByTestIdQueries } from './queries/test-id';\nimport { bindByTextQueries } from './queries/text';\nimport { bindUnsafeByPropsQueries } from './queries/unsafe-props';\nimport { bindUnsafeByTypeQueries } from './queries/unsafe-type';\n\nexport function within(instance: ReactTestInstance) {\n return {\n ...bindByTextQueries(instance),\n ...bindByTestIdQueries(instance),\n ...bindByDisplayValueQueries(instance),\n ...bindByPlaceholderTextQueries(instance),\n ...bindByLabelTextQueries(instance),\n ...bindByHintTextQueries(instance),\n ...bindByRoleQueries(instance),\n ...bindUnsafeByTypeQueries(instance),\n ...bindUnsafeByPropsQueries(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"mappings":";;;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAEO,SAASS,MAAMA,CAACC,QAA2B,EAAE;EAClD,OAAO;IACL,GAAG,IAAAC,uBAAiB,EAACD,QAAQ,CAAC;IAC9B,GAAG,IAAAE,2BAAmB,EAACF,QAAQ,CAAC;IAChC,GAAG,IAAAG,uCAAyB,EAACH,QAAQ,CAAC;IACtC,GAAG,IAAAI,6CAA4B,EAACJ,QAAQ,CAAC;IACzC,GAAG,IAAAK,iCAAsB,EAACL,QAAQ,CAAC;IACnC,GAAG,IAAAM,+BAAqB,EAACN,QAAQ,CAAC;IAClC,GAAG,IAAAO,uBAAiB,EAACP,QAAQ,CAAC;IAC9B,GAAG,IAAAQ,mCAAuB,EAACR,QAAQ,CAAC;IACpC,GAAG,IAAAS,qCAAwB,EAACT,QAAQ;EACtC,CAAC;AACH;AAEO,MAAMU,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGX,MAAM","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "13.0.0",
3
+ "version": "13.0.1",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -47,6 +47,7 @@
47
47
  "typings/index.flow.js"
48
48
  ],
49
49
  "dependencies": {
50
+ "chalk": "^4.1.2",
50
51
  "jest-matcher-utils": "^29.7.0",
51
52
  "pretty-format": "^29.7.0",
52
53
  "redent": "^3.0.0"
@@ -72,7 +73,7 @@
72
73
  "@babel/preset-typescript": "^7.26.0",
73
74
  "@callstack/eslint-config": "^15.0.0",
74
75
  "@react-native/babel-preset": "0.77.0-rc.0",
75
- "@release-it/conventional-changelog": "^9.0.2",
76
+ "@release-it/conventional-changelog": "^10.0.0",
76
77
  "@relmify/jest-serializer-strip-ansi": "^1.0.2",
77
78
  "@types/jest": "^29.5.14",
78
79
  "@types/react": "^18.3.12",
@@ -80,17 +81,17 @@
80
81
  "babel-jest": "^29.7.0",
81
82
  "babel-plugin-module-resolver": "^5.0.2",
82
83
  "del-cli": "^6.0.0",
83
- "eslint": "^8.57.1",
84
- "eslint-plugin-prettier": "^4.2.1",
84
+ "eslint": "^9.17.0",
85
+ "eslint-plugin-simple-import-sort": "^12.1.1",
85
86
  "flow-bin": "~0.170.0",
86
87
  "jest": "^29.7.0",
87
88
  "prettier": "^2.8.8",
88
89
  "react": "18.3.1",
89
90
  "react-native": "0.77.0-rc.0",
90
91
  "react-test-renderer": "18.3.1",
91
- "release-it": "^17.10.0",
92
- "strip-ansi": "^6.0.1",
93
- "typescript": "^5.6.3"
92
+ "release-it": "^18.0.0",
93
+ "typescript": "^5.6.3",
94
+ "typescript-eslint": "^8.19.1"
94
95
  },
95
96
  "publishConfig": {
96
97
  "registry": "https://registry.npmjs.org"
@@ -86,12 +86,12 @@ interface ByTextQueries {
86
86
  findByText: (
87
87
  text: TextMatch,
88
88
  queryOptions?: ByTextOptions,
89
- waitForOptions?: WaitForOptions
89
+ waitForOptions?: WaitForOptions,
90
90
  ) => FindReturn;
91
91
  findAllByText: (
92
92
  text: TextMatch,
93
93
  queryOptions?: ByTextOptions,
94
- waitForOptions?: WaitForOptions
94
+ waitForOptions?: WaitForOptions,
95
95
  ) => FindAllReturn;
96
96
  }
97
97
 
@@ -105,12 +105,12 @@ interface ByTestIdQueries {
105
105
  findByTestId: (
106
106
  testID: TextMatch,
107
107
  queryOptions?: ByTestIdOptions,
108
- waitForOptions?: WaitForOptions
108
+ waitForOptions?: WaitForOptions,
109
109
  ) => FindReturn;
110
110
  findAllByTestId: (
111
111
  testID: TextMatch,
112
112
  queryOptions?: ByTestIdOptions,
113
- waitForOptions?: WaitForOptions
113
+ waitForOptions?: WaitForOptions,
114
114
  ) => FindAllReturn;
115
115
  }
116
116
 
@@ -120,25 +120,25 @@ interface ByDisplayValueQueries {
120
120
  getByDisplayValue: (value: TextMatch, options?: ByDisplayValueOptions) => ReactTestInstance;
121
121
  getAllByDisplayValue: (
122
122
  value: TextMatch,
123
- options?: ByDisplayValueOptions
123
+ options?: ByDisplayValueOptions,
124
124
  ) => Array<ReactTestInstance>;
125
125
  queryByDisplayValue: (
126
126
  value: TextMatch,
127
- options?: ByDisplayValueOptions
127
+ options?: ByDisplayValueOptions,
128
128
  ) => ReactTestInstance | null;
129
129
  queryAllByDisplayValue: (
130
130
  value: TextMatch,
131
- options?: ByDisplayValueOptions
131
+ options?: ByDisplayValueOptions,
132
132
  ) => Array<ReactTestInstance> | [];
133
133
  findByDisplayValue: (
134
134
  value: TextMatch,
135
135
  queryOptions?: ByDisplayValueOptions,
136
- waitForOptions?: WaitForOptions
136
+ waitForOptions?: WaitForOptions,
137
137
  ) => FindReturn;
138
138
  findAllByDisplayValue: (
139
139
  value: TextMatch,
140
140
  queryOptions?: ByDisplayValueOptions,
141
- waitForOptions?: WaitForOptions
141
+ waitForOptions?: WaitForOptions,
142
142
  ) => FindAllReturn;
143
143
  }
144
144
 
@@ -147,29 +147,29 @@ type ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;
147
147
  interface ByPlaceholderTextQueries {
148
148
  getByPlaceholderText: (
149
149
  placeholder: TextMatch,
150
- options?: ByPlaceholderTextOptions
150
+ options?: ByPlaceholderTextOptions,
151
151
  ) => ReactTestInstance;
152
152
  getAllByPlaceholderText: (
153
153
  placeholder: TextMatch,
154
- options?: ByPlaceholderTextOptions
154
+ options?: ByPlaceholderTextOptions,
155
155
  ) => Array<ReactTestInstance>;
156
156
  queryByPlaceholderText: (
157
157
  placeholder: TextMatch,
158
- options?: ByPlaceholderTextOptions
158
+ options?: ByPlaceholderTextOptions,
159
159
  ) => ReactTestInstance | null;
160
160
  queryAllByPlaceholderText: (
161
161
  placeholder: TextMatch,
162
- options?: ByPlaceholderTextOptions
162
+ options?: ByPlaceholderTextOptions,
163
163
  ) => Array<ReactTestInstance> | [];
164
164
  findByPlaceholderText: (
165
165
  placeholder: TextMatch,
166
166
  queryOptions?: ByPlaceholderTextOptions,
167
- waitForOptions?: WaitForOptions
167
+ waitForOptions?: WaitForOptions,
168
168
  ) => FindReturn;
169
169
  findAllByPlaceholderText: (
170
170
  placeholder: TextMatch,
171
171
  queryOptions?: ByPlaceholderTextOptions,
172
- waitForOptions?: WaitForOptions
172
+ waitForOptions?: WaitForOptions,
173
173
  ) => FindAllReturn;
174
174
  }
175
175
 
@@ -205,12 +205,12 @@ interface A11yAPI {
205
205
  findByLabelText: (
206
206
  matcher: TextMatch,
207
207
  queryOptions?: ByLabelTextOptions,
208
- waitForOptions?: WaitForOptions
208
+ waitForOptions?: WaitForOptions,
209
209
  ) => FindReturn;
210
210
  findAllByLabelText: (
211
211
  matcher: TextMatch,
212
212
  queryOptions?: ByLabelTextOptions,
213
- waitForOptions?: WaitForOptions
213
+ waitForOptions?: WaitForOptions,
214
214
  ) => FindAllReturn;
215
215
 
216
216
  // Hint
@@ -225,22 +225,22 @@ interface A11yAPI {
225
225
  findByA11yHint: (
226
226
  matcher: TextMatch,
227
227
  queryOptions?: ByHintTextOptions,
228
- waitForOptions?: WaitForOptions
228
+ waitForOptions?: WaitForOptions,
229
229
  ) => FindReturn;
230
230
  findByHintText: (
231
231
  matcher: TextMatch,
232
232
  queryOptions?: ByHintTextOptions,
233
- waitForOptions?: WaitForOptions
233
+ waitForOptions?: WaitForOptions,
234
234
  ) => FindReturn;
235
235
  findAllByA11yHint: (
236
236
  matcher: TextMatch,
237
237
  queryOptions?: ByHintTextOptions,
238
- waitForOptions?: WaitForOptions
238
+ waitForOptions?: WaitForOptions,
239
239
  ) => FindAllReturn;
240
240
  findAllByHintText: (
241
241
  matcher: TextMatch,
242
242
  queryOptions?: ByHintTextOptions,
243
- waitForOptions?: WaitForOptions
243
+ waitForOptions?: WaitForOptions,
244
244
  ) => FindAllReturn;
245
245
 
246
246
  // Role
@@ -251,12 +251,12 @@ interface A11yAPI {
251
251
  findByRole: (
252
252
  matcher: A11yRole | RegExp,
253
253
  queryOptions?: ByRoleOptions,
254
- waitForOptions?: WaitForOptions
254
+ waitForOptions?: WaitForOptions,
255
255
  ) => FindReturn;
256
256
  findAllByRole: (
257
257
  matcher: A11yRole | RegExp,
258
258
  queryOptions?: ByRoleOptions,
259
- waitForOptions?: WaitForOptions
259
+ waitForOptions?: WaitForOptions,
260
260
  ) => FindAllReturn;
261
261
  }
262
262
 
@@ -266,7 +266,7 @@ interface Thenable {
266
266
 
267
267
  type MapPropsFunction = (
268
268
  props: { [string]: mixed },
269
- node: ReactTestRendererJSON
269
+ node: ReactTestRendererJSON,
270
270
  ) => { [string]: mixed };
271
271
 
272
272
  type DebugOptions = {
@@ -274,10 +274,6 @@ type DebugOptions = {
274
274
  mapProps?: MapPropsFunction,
275
275
  };
276
276
 
277
- type Debug = {
278
- (options?: DebugOptions | string): void,
279
- };
280
-
281
277
  type Queries = ByTextQueries &
282
278
  ByTestIdQueries &
283
279
  ByDisplayValueQueries &
@@ -304,7 +300,7 @@ declare module '@testing-library/react-native' {
304
300
  rerender(nextElement: React.Element<any>): void;
305
301
  unmount(nextElement?: React.Element<any>): void;
306
302
  toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
307
- debug: Debug;
303
+ debug(options?: DebugOptions): void;
308
304
  root: ReactTestInstance;
309
305
  UNSAFE_root: ReactTestInstance;
310
306
  }
@@ -322,7 +318,7 @@ declare module '@testing-library/react-native' {
322
318
 
323
319
  declare export var render: (
324
320
  component: React.Element<any>,
325
- options?: RenderOptions
321
+ options?: RenderOptions,
326
322
  ) => RenderResult;
327
323
 
328
324
  declare export var screen: RenderResult;
@@ -334,7 +330,7 @@ declare module '@testing-library/react-native' {
334
330
 
335
331
  declare type WaitForElementToBeRemovedFunction = <T = any>(
336
332
  expectation: () => T,
337
- options?: WaitForOptions
333
+ options?: WaitForOptions,
338
334
  ) => Promise<T>;
339
335
 
340
336
  declare export var waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
@@ -375,7 +371,7 @@ declare module '@testing-library/react-native' {
375
371
 
376
372
  declare type RenderHookFunction = <Result, Props>(
377
373
  renderCallback: (props: Props) => Result,
378
- options?: RenderHookOptions<Props>
374
+ options?: RenderHookOptions<Props>,
379
375
  ) => RenderHookResult<Result, Props>;
380
376
 
381
377
  declare export var renderHook: RenderHookFunction;
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-default.js","names":["_reactNative","require","_object","propsToDisplay","defaultMapProps","props","result","styles","StyleSheet","flatten","style","styleToDisplay","extractStyle","undefined","accessibilityState","removeUndefinedKeys","accessibilityValue","forEach","propName","display","opacity","hasAnyKeys","Object","keys","length"],"sources":["../../src/helpers/format-default.ts"],"sourcesContent":["import { StyleSheet, ViewStyle } from 'react-native';\nimport { removeUndefinedKeys } from './object';\n\nconst propsToDisplay = [\n 'accessible',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityRole',\n 'accessibilityViewIsModal',\n 'alt',\n 'aria-busy',\n 'aria-checked',\n 'aria-disabled',\n 'aria-expanded',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'aria-modal',\n 'aria-selected',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext',\n 'defaultValue',\n 'importantForAccessibility',\n 'nativeID',\n 'placeholder',\n 'role',\n 'testID',\n 'title',\n 'value',\n] as const;\n\n/**\n * Preserve props that are helpful in diagnosing test failures, while stripping rest\n */\nexport function defaultMapProps(props: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n const styles = StyleSheet.flatten(props.style as ViewStyle);\n const styleToDisplay = extractStyle(styles);\n if (styleToDisplay !== undefined) {\n result.style = styleToDisplay;\n }\n\n const accessibilityState = removeUndefinedKeys(props.accessibilityState);\n if (accessibilityState !== undefined) {\n result.accessibilityState = accessibilityState;\n }\n\n const accessibilityValue = removeUndefinedKeys(props.accessibilityValue);\n if (accessibilityValue !== undefined) {\n result.accessibilityValue = accessibilityValue;\n }\n\n propsToDisplay.forEach((propName) => {\n if (propName in props) {\n result[propName] = props[propName];\n }\n });\n\n return result;\n}\n\nfunction extractStyle(style: ViewStyle | undefined) {\n if (style == null) {\n return undefined;\n }\n\n const result: Record<string, unknown> = {};\n if (style.display === 'none') {\n result.display = 'none';\n }\n\n if (style.opacity === 0) {\n result.opacity = 0;\n }\n\n const hasAnyKeys = Object.keys(result).length > 0;\n return hasAnyKeys ? result : undefined;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,cAAc,GAAG,CACrB,YAAY,EACZ,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,2BAA2B,EAC3B,UAAU,EACV,aAAa,EACb,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,CACC;;AAEV;AACA;AACA;AACO,SAASC,eAAeA,CAACC,KAA8B,EAA2B;EACvF,MAAMC,MAA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xC","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- import type { ReactTestRendererJSON } from 'react-test-renderer';
2
- export type MapPropsFunction = (props: Record<string, unknown>, node: ReactTestRendererJSON) => Record<string, unknown>;
3
- export type FormatOptions = {
4
- mapProps?: MapPropsFunction;
5
- };
6
- declare const format: (input: ReactTestRendererJSON | ReactTestRendererJSON[], options?: FormatOptions) => string;
7
- export default format;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _prettyFormat = _interopRequireWildcard(require("pretty-format"));
8
- 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); }
9
- 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; }
10
- const format = (input, options = {}) => (0, _prettyFormat.default)(input, {
11
- plugins: [getCustomPlugin(options.mapProps), _prettyFormat.plugins.ReactElement],
12
- highlight: true,
13
- printBasicPrototype: false
14
- });
15
- const getCustomPlugin = mapProps => {
16
- return {
17
- test: val => _prettyFormat.plugins.ReactTestComponent.test(val),
18
- serialize: (val, config, indentation, depth, refs, printer) => {
19
- let newVal = val;
20
- if (mapProps && val.props) {
21
- newVal = {
22
- ...val,
23
- props: mapProps(val.props, val)
24
- };
25
- }
26
- return _prettyFormat.plugins.ReactTestComponent.serialize(newVal, config, indentation, depth, refs, printer);
27
- }
28
- };
29
- };
30
- var _default = exports.default = format;
31
- //# sourceMappingURL=format.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.js","names":["_prettyFormat","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","format","input","options","prettyFormat","plugins","getCustomPlugin","mapProps","ReactElement","highlight","printBasicPrototype","test","val","ReactTestComponent","serialize","config","indentation","depth","refs","printer","newVal","props","_default","exports"],"sources":["../../src/helpers/format.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport prettyFormat, { NewPlugin, plugins } from 'pretty-format';\n\nexport type MapPropsFunction = (\n props: Record<string, unknown>,\n node: ReactTestRendererJSON,\n) => Record<string, unknown>;\n\nexport type FormatOptions = {\n mapProps?: MapPropsFunction;\n};\n\nconst format = (\n input: ReactTestRendererJSON | ReactTestRendererJSON[],\n options: FormatOptions = {},\n) =>\n prettyFormat(input, {\n plugins: [getCustomPlugin(options.mapProps), plugins.ReactElement],\n highlight: true,\n printBasicPrototype: false,\n });\n\nconst getCustomPlugin = (mapProps?: MapPropsFunction): NewPlugin => {\n return {\n test: (val) => plugins.ReactTestComponent.test(val),\n serialize: (val, config, indentation, depth, refs, printer) => {\n let newVal = val;\n if (mapProps && val.props) {\n newVal = { ...val, props: mapProps(val.props, val) };\n }\n return plugins.ReactTestComponent.serialize(\n newVal,\n config,\n indentation,\n depth,\n refs,\n printer,\n );\n },\n };\n};\n\nexport default format;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiE,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CA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