@testing-library/react-native 12.2.2 → 12.3.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 (164) hide show
  1. package/build/act.js +1 -2
  2. package/build/act.js.map +1 -1
  3. package/build/config.d.ts +2 -0
  4. package/build/config.js.map +1 -1
  5. package/build/fireEvent.js +3 -3
  6. package/build/fireEvent.js.map +1 -1
  7. package/build/helpers/accessiblity.d.ts +11 -0
  8. package/build/helpers/accessiblity.js +108 -8
  9. package/build/helpers/accessiblity.js.map +1 -1
  10. package/build/helpers/component-tree.d.ts +7 -0
  11. package/build/helpers/component-tree.js +18 -0
  12. package/build/helpers/component-tree.js.map +1 -1
  13. package/build/helpers/format-default.d.ts +1 -2
  14. package/build/helpers/format-default.js +22 -13
  15. package/build/helpers/format-default.js.map +1 -1
  16. package/build/helpers/format.js +4 -8
  17. package/build/helpers/format.js.map +1 -1
  18. package/build/helpers/host-component-names.d.ts +10 -0
  19. package/build/helpers/host-component-names.js +27 -3
  20. package/build/helpers/host-component-names.js.map +1 -1
  21. package/build/helpers/matchers/accessibilityState.js +3 -3
  22. package/build/helpers/matchers/accessibilityState.js.map +1 -1
  23. package/build/helpers/matchers/accessibilityValue.js +3 -2
  24. package/build/helpers/matchers/accessibilityValue.js.map +1 -1
  25. package/build/helpers/matchers/matchLabelText.d.ts +1 -1
  26. package/build/helpers/matchers/matchLabelText.js +5 -8
  27. package/build/helpers/matchers/matchLabelText.js.map +1 -1
  28. package/build/helpers/matchers/matchTextContent.js +2 -2
  29. package/build/helpers/matchers/matchTextContent.js.map +1 -1
  30. package/build/helpers/object.d.ts +1 -0
  31. package/build/helpers/object.js +16 -0
  32. package/build/helpers/object.js.map +1 -0
  33. package/build/helpers/{getTextContent.js → text-content.js} +1 -1
  34. package/build/helpers/text-content.js.map +1 -0
  35. package/build/helpers/text-input.d.ts +3 -0
  36. package/build/helpers/text-input.js +21 -0
  37. package/build/helpers/text-input.js.map +1 -0
  38. package/build/helpers/wrap-async.d.ts +7 -0
  39. package/build/helpers/wrap-async.js +45 -0
  40. package/build/helpers/wrap-async.js.map +1 -0
  41. package/build/matchers/extend-expect.d.js +2 -0
  42. package/build/matchers/extend-expect.d.js.map +1 -0
  43. package/build/matchers/extend-expect.d.ts +2 -0
  44. package/build/matchers/extend-expect.js +38 -0
  45. package/build/matchers/extend-expect.js.map +1 -0
  46. package/build/matchers/index.d.ts +15 -0
  47. package/build/matchers/index.js +117 -0
  48. package/build/matchers/index.js.map +1 -0
  49. package/build/matchers/to-be-busy.d.ts +6 -0
  50. package/build/matchers/to-be-busy.js +20 -0
  51. package/build/matchers/to-be-busy.js.map +1 -0
  52. package/build/matchers/to-be-checked.d.ts +6 -0
  53. package/build/matchers/to-be-checked.js +31 -0
  54. package/build/matchers/to-be-checked.js.map +1 -0
  55. package/build/matchers/to-be-collapsed.d.ts +6 -0
  56. package/build/matchers/to-be-collapsed.js +20 -0
  57. package/build/matchers/to-be-collapsed.js.map +1 -0
  58. package/build/matchers/to-be-disabled.d.ts +10 -0
  59. package/build/matchers/to-be-disabled.js +52 -0
  60. package/build/matchers/to-be-disabled.js.map +1 -0
  61. package/build/matchers/to-be-empty-element.d.ts +6 -0
  62. package/build/matchers/to-be-empty-element.js +20 -0
  63. package/build/matchers/to-be-empty-element.js.map +1 -0
  64. package/build/matchers/to-be-expanded.d.ts +6 -0
  65. package/build/matchers/to-be-expanded.js +20 -0
  66. package/build/matchers/to-be-expanded.js.map +1 -0
  67. package/build/matchers/to-be-on-the-screen.d.ts +6 -0
  68. package/build/matchers/to-be-on-the-screen.js +29 -0
  69. package/build/matchers/to-be-on-the-screen.js.map +1 -0
  70. package/build/matchers/to-be-partially-checked.d.ts +6 -0
  71. package/build/matchers/to-be-partially-checked.js +28 -0
  72. package/build/matchers/to-be-partially-checked.js.map +1 -0
  73. package/build/matchers/to-be-selected.d.ts +6 -0
  74. package/build/matchers/to-be-selected.js +20 -0
  75. package/build/matchers/to-be-selected.js.map +1 -0
  76. package/build/matchers/to-be-visible.d.ts +6 -0
  77. package/build/matchers/to-be-visible.js +56 -0
  78. package/build/matchers/to-be-visible.js.map +1 -0
  79. package/build/matchers/to-contain-element.d.ts +6 -0
  80. package/build/matchers/to-contain-element.js +26 -0
  81. package/build/matchers/to-contain-element.js.map +1 -0
  82. package/build/matchers/to-have-display-value.d.ts +7 -0
  83. package/build/matchers/to-have-display-value.js +26 -0
  84. package/build/matchers/to-have-display-value.js.map +1 -0
  85. package/build/matchers/to-have-prop.d.ts +6 -0
  86. package/build/matchers/to-have-prop.js +35 -0
  87. package/build/matchers/to-have-prop.js.map +1 -0
  88. package/build/matchers/to-have-style.d.ts +8 -0
  89. package/build/matchers/to-have-style.js +52 -0
  90. package/build/matchers/to-have-style.js.map +1 -0
  91. package/build/matchers/to-have-text-content.d.ts +7 -0
  92. package/build/matchers/to-have-text-content.js +21 -0
  93. package/build/matchers/to-have-text-content.js.map +1 -0
  94. package/build/matchers/utils.d.ts +18 -0
  95. package/build/matchers/utils.js +90 -0
  96. package/build/matchers/utils.js.map +1 -0
  97. package/build/matches.d.ts +1 -1
  98. package/build/matches.js.map +1 -1
  99. package/build/queries/displayValue.js +4 -3
  100. package/build/queries/displayValue.js.map +1 -1
  101. package/build/queries/labelText.js +2 -2
  102. package/build/queries/labelText.js.map +1 -1
  103. package/build/queries/role.js +1 -1
  104. package/build/queries/role.js.map +1 -1
  105. package/build/react-versions.js +2 -2
  106. package/build/react-versions.js.map +1 -1
  107. package/build/render.d.ts +12 -48
  108. package/build/render.js +5 -4
  109. package/build/render.js.map +1 -1
  110. package/build/screen.js +1 -2
  111. package/build/screen.js.map +1 -1
  112. package/build/shallow.js +2 -2
  113. package/build/shallow.js.map +1 -1
  114. package/build/test-utils/events.d.ts +1 -2
  115. package/build/test-utils/events.js.map +1 -1
  116. package/build/user-event/clear.js +2 -1
  117. package/build/user-event/clear.js.map +1 -1
  118. package/build/user-event/event-builder/common.js +1 -2
  119. package/build/user-event/event-builder/common.js.map +1 -1
  120. package/build/user-event/event-builder/index.d.ts +30 -0
  121. package/build/user-event/event-builder/index.js +3 -2
  122. package/build/user-event/event-builder/index.js.map +1 -1
  123. package/build/user-event/event-builder/scroll-view.d.ts +42 -0
  124. package/build/user-event/event-builder/scroll-view.js +52 -0
  125. package/build/user-event/event-builder/scroll-view.js.map +1 -0
  126. package/build/user-event/event-builder/text-input.js +1 -2
  127. package/build/user-event/event-builder/text-input.js.map +1 -1
  128. package/build/user-event/index.d.ts +2 -0
  129. package/build/user-event/index.js +3 -3
  130. package/build/user-event/index.js.map +1 -1
  131. package/build/user-event/press/constants.js +2 -4
  132. package/build/user-event/press/constants.js.map +1 -1
  133. package/build/user-event/press/press.js +11 -14
  134. package/build/user-event/press/press.js.map +1 -1
  135. package/build/user-event/scroll/index.d.ts +1 -0
  136. package/build/user-event/scroll/index.js +19 -0
  137. package/build/user-event/scroll/index.js.map +1 -0
  138. package/build/user-event/scroll/scrollTo.d.ts +16 -0
  139. package/build/user-event/scroll/scrollTo.js +82 -0
  140. package/build/user-event/scroll/scrollTo.js.map +1 -0
  141. package/build/user-event/scroll/state.d.ts +4 -0
  142. package/build/user-event/scroll/state.js +18 -0
  143. package/build/user-event/scroll/state.js.map +1 -0
  144. package/build/user-event/scroll/utils.d.ts +20 -0
  145. package/build/user-event/scroll/utils.js +68 -0
  146. package/build/user-event/scroll/utils.js.map +1 -0
  147. package/build/user-event/setup/setup.d.ts +8 -0
  148. package/build/user-event/setup/setup.js +34 -6
  149. package/build/user-event/setup/setup.js.map +1 -1
  150. package/build/user-event/type/type.js +2 -1
  151. package/build/user-event/type/type.js.map +1 -1
  152. package/build/user-event/utils/index.d.ts +0 -1
  153. package/build/user-event/utils/index.js +0 -11
  154. package/build/user-event/utils/index.js.map +1 -1
  155. package/build/waitFor.js +2 -26
  156. package/build/waitFor.js.map +1 -1
  157. package/build/within.js +1 -2
  158. package/build/within.js.map +1 -1
  159. package/package.json +23 -37
  160. package/build/helpers/getTextContent.js.map +0 -1
  161. package/build/user-event/utils/host-components.d.ts +0 -2
  162. package/build/user-event/utils/host-components.js +0 -11
  163. package/build/user-event/utils/host-components.js.map +0 -1
  164. /package/build/helpers/{getTextContent.d.ts → text-content.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"waitFor.js","names":["_act","_interopRequireWildcard","require","_config","_flushMicroTasks","_errors","_timers","_reactVersions","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","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","checkReactVersionAtLeast","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","flushMicroTasksLegacy","act"],"sources":["../src/waitFor.ts"],"sourcesContent":["/* globals jest */\nimport act, { setReactActEnvironment, getIsReactActEnvironment } from './act';\nimport { getConfig } from './config';\nimport { flushMicroTasks, flushMicroTasksLegacy } from './flush-micro-tasks';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n jestFakeTimersAreEnabled,\n} from './helpers/timers';\nimport { checkReactVersionAtLeast } from './react-versions';\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(\n done: { type: 'result'; result: T } | { type: 'error'; error: unknown }\n ) {\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 async function waitFor<T>(\n expectation: () => T,\n options?: WaitForOptions\n): 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 if (checkReactVersionAtLeast(18, 0)) {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await waitForInternal(expectation, optionsWithStackTrace);\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasksLegacy();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n }\n\n if (!checkReactVersionAtLeast(16, 9)) {\n return waitForInternal(expectation, optionsWithStackTrace);\n }\n\n let result: T;\n\n await act(async () => {\n result = await waitForInternal(expectation, optionsWithStackTrace);\n });\n\n // Either we have result or `waitFor` threw error\n return result!;\n}\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,cAAA,GAAAL,OAAA;AAA4D,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAR,wBAAAY,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBA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,EAACF,sBAAsB,CAAC;IAChD;EACF;EAEA,IAAI,CAAC,IAAAD,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE;IACpC,OAAO9C,eAAe,CAACC,WAAW,EAAE4C,qBAAqB,CAAC;EAC5D;EAEA,IAAIT,MAAS;EAEb,MAAM,IAAAe,YAAG,EAAC,YAAY;IACpBf,MAAM,GAAG,MAAMpC,eAAe,CAACC,WAAW,EAAE4C,qBAAqB,CAAC;EACpE,CAAC,CAAC;;EAEF;EACA,OAAOT,MAAM;AACf"}
1
+ {"version":3,"file":"waitFor.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/waitFor.ts"],"sourcesContent":["/* globals jest */\nimport { getConfig } from './config';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n jestFakeTimersAreEnabled,\n} 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(\n done: { type: 'result'; result: T } | { type: 'error'; error: unknown }\n ) {\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 async function waitFor<T>(\n expectation: () => T,\n options?: WaitForOptions\n): 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;AAKA,IAAAI,UAAA,GAAAJ,OAAA;AATA;;AAWA,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,CAAC,+CAA+C,CAAC;EACtE;;EAEA;EACA,OAAO,IAAIC,OAAO,CAAC,OAAOC,OAAO,EAAEC,MAAM,KAAK;IAC5C,IAAIC,SAAkB,EAAEC,UAAyC;IACjE,IAAIC,QAAQ,GAAG,KAAK;IACpB,IAAIC,aAAa,GAAG,MAAM;IAE1B,IAAIC,mBAA0C,GAAG,IAAI;IAErD,MAAMC,eAAe,GAAG,IAAAC,gCAAwB,EAAC,CAAC;IAElD,IAAID,eAAe,EAAE;MACnBE,gBAAgB,CAAC,CAAC;MAClB;MACA;MACA;MACA;MACA;MACA,IAAIC,iBAAiB,GAAGlB,OAAO;MAC/B,OAAO,CAACY,QAAQ,EAAE;QAChB,IAAI,CAAC,IAAAI,gCAAwB,EAAC,CAAC,EAAE;UAC/B,MAAMG,KAAK,GAAG,IAAIC,KAAK,CACpB,kUACH,CAAC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eAAe,EAAE;UACnB,IAAAiB,sBAAc,EAACF,KAAK,EAAEf,eAAe,CAAC;QACxC;MACF;MACA,IAAI,OAAOC,SAAS,KAAK,UAAU,EAAE;QACnC,MAAM6B,MAAM,GAAG7B,SAAS,CAACc,KAAK,CAAC;QAC/B,IAAIe,MAAM,EAAE;UACVf,KAAK,GAAGe,MAAM;QAChB;MACF;MACAL,MAAM,CAAC;QAAEI,IAAI,EAAE,OAAO;QAAEd;MAAM,CAAC,CAAC;IAClC;EACF,CAAC,CAAC;AACJ;AAEe,eAAeqB,OAAOA,CACnCzC,WAAoB,EACpB0C,OAAwB,EACZ;EACZ;EACA,MAAMrC,eAAe,GAAG,IAAIsC,sBAAc,CAAC,mBAAmB,EAAEF,OAAO,CAAC;EACxE,MAAMG,qBAAqB,GAAG;IAAEvC,eAAe;IAAE,GAAGqC;EAAQ,CAAC;EAE7D,OAAO,IAAAG,oBAAS,EAAC,MAAM9C,eAAe,CAACC,WAAW,EAAE4C,qBAAqB,CAAC,CAAC;AAC7E"}
package/build/within.js CHANGED
@@ -31,6 +31,5 @@ function within(instance) {
31
31
  ...(0, _unsafeProps.bindUnsafeByPropsQueries)(instance)
32
32
  };
33
33
  }
34
- const getQueriesForElement = within;
35
- exports.getQueriesForElement = getQueriesForElement;
34
+ const getQueriesForElement = exports.getQueriesForElement = within;
36
35
  //# sourceMappingURL=within.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"within.js","names":["_text","require","_testId","_displayValue","_placeholderText","_labelText","_hintText","_role","_a11yState","_a11yValue","_unsafeType","_unsafeProps","within","instance","bindByTextQueries","bindByTestIdQueries","bindByDisplayValueQueries","bindByPlaceholderTextQueries","bindByLabelTextQueries","bindByHintTextQueries","bindByRoleQueries","bindByA11yStateQueries","bindByA11yValueQueries","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/testId';\nimport { bindByDisplayValueQueries } from './queries/displayValue';\nimport { bindByPlaceholderTextQueries } from './queries/placeholderText';\nimport { bindByLabelTextQueries } from './queries/labelText';\nimport { bindByHintTextQueries } from './queries/hintText';\nimport { bindByRoleQueries } from './queries/role';\nimport { bindByA11yStateQueries } from './queries/a11yState';\nimport { bindByA11yValueQueries } from './queries/a11yValue';\nimport { bindUnsafeByTypeQueries } from './queries/unsafeType';\nimport { bindUnsafeByPropsQueries } from './queries/unsafeProps';\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 ...bindByA11yStateQueries(instance),\n ...bindByA11yValueQueries(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,UAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AAEO,SAASW,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,iCAAsB,EAACR,QAAQ,CAAC;IACnC,GAAG,IAAAS,iCAAsB,EAACT,QAAQ,CAAC;IACnC,GAAG,IAAAU,mCAAuB,EAACV,QAAQ,CAAC;IACpC,GAAG,IAAAW,qCAAwB,EAACX,QAAQ;EACtC,CAAC;AACH;AAEO,MAAMY,oBAAoB,GAAGb,MAAM;AAACc,OAAA,CAAAD,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"file":"within.js","names":["_text","require","_testId","_displayValue","_placeholderText","_labelText","_hintText","_role","_a11yState","_a11yValue","_unsafeType","_unsafeProps","within","instance","bindByTextQueries","bindByTestIdQueries","bindByDisplayValueQueries","bindByPlaceholderTextQueries","bindByLabelTextQueries","bindByHintTextQueries","bindByRoleQueries","bindByA11yStateQueries","bindByA11yValueQueries","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/testId';\nimport { bindByDisplayValueQueries } from './queries/displayValue';\nimport { bindByPlaceholderTextQueries } from './queries/placeholderText';\nimport { bindByLabelTextQueries } from './queries/labelText';\nimport { bindByHintTextQueries } from './queries/hintText';\nimport { bindByRoleQueries } from './queries/role';\nimport { bindByA11yStateQueries } from './queries/a11yState';\nimport { bindByA11yValueQueries } from './queries/a11yValue';\nimport { bindUnsafeByTypeQueries } from './queries/unsafeType';\nimport { bindUnsafeByPropsQueries } from './queries/unsafeProps';\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 ...bindByA11yStateQueries(instance),\n ...bindByA11yValueQueries(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,UAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AAEO,SAASW,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,iCAAsB,EAACR,QAAQ,CAAC;IACnC,GAAG,IAAAS,iCAAsB,EAACT,QAAQ,CAAC;IACnC,GAAG,IAAAU,mCAAuB,EAACV,QAAQ,CAAC;IACpC,GAAG,IAAAW,qCAAwB,EAACX,QAAQ;EACtC,CAAC;AACH;AAEO,MAAMY,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGb,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "12.2.2",
3
+ "version": "12.3.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",
@@ -32,34 +32,36 @@
32
32
  "dont-cleanup-after-each.js"
33
33
  ],
34
34
  "devDependencies": {
35
- "@babel/cli": "^7.19.3",
36
- "@babel/core": "^7.20.2",
37
- "@babel/plugin-proposal-class-properties": "^7.18.6",
38
- "@babel/plugin-transform-flow-strip-types": "^7.19.0",
39
- "@babel/preset-env": "^7.20.2",
40
- "@babel/preset-flow": "^7.18.6",
41
- "@babel/preset-react": "^7.18.6",
42
- "@babel/preset-typescript": "^7.18.6",
35
+ "@babel/cli": "^7.22.15",
36
+ "@babel/core": "^7.22.20",
37
+ "@babel/plugin-transform-flow-strip-types": "^7.22.5",
38
+ "@babel/preset-env": "^7.22.20",
39
+ "@babel/preset-flow": "^7.22.15",
40
+ "@babel/preset-react": "^7.22.15",
41
+ "@babel/preset-typescript": "^7.22.15",
43
42
  "@callstack/eslint-config": "^13.0.1",
44
- "@testing-library/jest-native": "^5.4.0",
45
- "@types/jest": "^29.2.3",
46
- "@types/react": "^18.2.15",
47
- "@types/react-test-renderer": "^18.0.0",
48
- "babel-jest": "^29.4.0",
43
+ "@relmify/jest-serializer-strip-ansi": "^1.0.2",
44
+ "@types/jest": "^29.5.5",
45
+ "@types/react": "^18.2.21",
46
+ "@types/react-test-renderer": "^18.0.2",
47
+ "babel-jest": "^29.7.0",
49
48
  "dedent": "^1.1.0",
50
49
  "del-cli": "^5.0.0",
51
50
  "eslint": "^8.21.0",
51
+ "eslint-plugin-flowtype": "^8.0.3",
52
52
  "flow-bin": "~0.170.0",
53
53
  "flow-copy-source": "^2.0.9",
54
- "jest": "^29.4.0",
54
+ "jest": "^29.7.0",
55
55
  "react": "18.2.0",
56
- "react-native": "0.71.4",
56
+ "react-native": "0.72.4",
57
57
  "react-test-renderer": "18.2.0",
58
- "strip-ansi": "^6.0.0",
59
- "typescript": "^5.0.2"
58
+ "strip-ansi": "^6.0.1",
59
+ "typescript": "^5.2.2"
60
60
  },
61
61
  "dependencies": {
62
- "pretty-format": "^29.0.0"
62
+ "jest-matcher-utils": "^29.7.0",
63
+ "pretty-format": "^29.7.0",
64
+ "redent": "^3.0.0"
63
65
  },
64
66
  "peerDependencies": {
65
67
  "jest": ">=28.0.0",
@@ -76,11 +78,12 @@
76
78
  "clean": "del build",
77
79
  "test": "jest",
78
80
  "test:ci": "jest --maxWorkers=2 --collectCoverage=true --coverage-provider=v8",
79
- "test:ci:react:17": "scripts/test_react_17",
81
+ "test:react-17": "scripts/test_react_17",
80
82
  "typecheck": "tsc",
81
83
  "flow": "flow",
82
84
  "copy-flowtypes": "cp typings/index.flow.js build",
83
85
  "lint": "eslint src --cache",
86
+ "validate": "yarn lint && yarn typecheck && yarn test",
84
87
  "prepublish": "yarn build",
85
88
  "build:js": "babel src --out-dir build --extensions \".js,.ts,.jsx,.tsx\" --source-maps --ignore \"**/__tests__/**\"",
86
89
  "build:js:watch": "yarn build:js --watch",
@@ -88,22 +91,5 @@
88
91
  "build:ts:watch": "yarn build:ts --watch --preserveWatchOutput",
89
92
  "build": "yarn clean && yarn build:js && yarn build:ts && yarn copy-flowtypes",
90
93
  "prepare": "yarn build"
91
- },
92
- "jest": {
93
- "preset": "./jest-preset",
94
- "setupFilesAfterEnv": [
95
- "./jest-setup.ts"
96
- ],
97
- "testPathIgnorePatterns": [
98
- "timerUtils",
99
- "examples/",
100
- "experiments-app/",
101
- "experiments-rtl/"
102
- ],
103
- "testTimeout": 60000,
104
- "transformIgnorePatterns": [
105
- "/node_modules/(?!(@react-native|react-native)/).*/"
106
- ],
107
- "clearMocks": true
108
94
  }
109
95
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"getTextContent.js","names":["getTextContent","element","result","children","forEach","child","push","join"],"sources":["../../src/helpers/getTextContent.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nexport function getTextContent(\n element: ReactTestInstance | string | null\n): string {\n if (!element) {\n return '';\n }\n\n if (typeof element === 'string') {\n return element;\n }\n\n const result: string[] = [];\n element.children?.forEach((child) => {\n result.push(getTextContent(child));\n });\n\n return result.join('');\n}\n"],"mappings":";;;;;;AAEO,SAASA,cAAcA,CAC5BC,OAA0C,EAClC;EACR,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,EAAE;EACX;EAEA,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAMC,MAAgB,GAAG,EAAE;EAC3BD,OAAO,CAACE,QAAQ,EAAEC,OAAO,CAAEC,KAAK,IAAK;IACnCH,MAAM,CAACI,IAAI,CAACN,cAAc,CAACK,KAAK,CAAC,CAAC;EACpC,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACK,IAAI,CAAC,EAAE,CAAC;AACxB"}
@@ -1,2 +0,0 @@
1
- import { ReactTestInstance } from 'react-test-renderer';
2
- export declare function isEditableTextInput(element: ReactTestInstance): boolean;
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isEditableTextInput = isEditableTextInput;
7
- var _hostComponentNames = require("../../helpers/host-component-names");
8
- function isEditableTextInput(element) {
9
- return (0, _hostComponentNames.isHostTextInput)(element) && element.props.editable !== false;
10
- }
11
- //# sourceMappingURL=host-components.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"host-components.js","names":["_hostComponentNames","require","isEditableTextInput","element","isHostTextInput","props","editable"],"sources":["../../../src/user-event/utils/host-components.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { isHostTextInput } from '../../helpers/host-component-names';\n\nexport function isEditableTextInput(element: ReactTestInstance) {\n return isHostTextInput(element) && element.props.editable !== false;\n}\n"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AAEO,SAASC,mBAAmBA,CAACC,OAA0B,EAAE;EAC9D,OAAO,IAAAC,mCAAe,EAACD,OAAO,CAAC,IAAIA,OAAO,CAACE,KAAK,CAACC,QAAQ,KAAK,KAAK;AACrE"}