@testing-library/react-native 9.1.0 → 10.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 (121) hide show
  1. package/README.md +2 -2
  2. package/build/act.d.ts +3 -0
  3. package/build/act.js +2 -1
  4. package/build/act.js.map +1 -0
  5. package/build/cleanup.d.ts +5 -0
  6. package/build/cleanup.js +3 -2
  7. package/build/cleanup.js.map +1 -0
  8. package/build/fireEvent.d.ts +8 -0
  9. package/build/fireEvent.js +2 -1
  10. package/build/fireEvent.js.map +1 -0
  11. package/build/flushMicroTasks.d.ts +5 -0
  12. package/build/flushMicroTasks.js +2 -12
  13. package/build/flushMicroTasks.js.map +1 -0
  14. package/build/helpers/debugDeep.d.ts +5 -0
  15. package/build/helpers/debugDeep.js +4 -1
  16. package/build/helpers/debugDeep.js.map +1 -0
  17. package/build/helpers/debugShallow.d.ts +6 -0
  18. package/build/helpers/debugShallow.js +4 -7
  19. package/build/helpers/debugShallow.js.map +1 -0
  20. package/build/helpers/errors.d.ts +10 -0
  21. package/build/helpers/errors.js +29 -9
  22. package/build/helpers/errors.js.map +1 -0
  23. package/build/helpers/filterNodeByType.d.ts +3 -0
  24. package/build/helpers/filterNodeByType.js +2 -1
  25. package/build/helpers/filterNodeByType.js.map +1 -0
  26. package/build/helpers/format.d.ts +3 -0
  27. package/build/helpers/format.js +4 -3
  28. package/build/helpers/format.js.map +1 -0
  29. package/build/helpers/timers.d.ts +6 -0
  30. package/build/helpers/timers.js +9 -6
  31. package/build/helpers/timers.js.map +1 -0
  32. package/build/index.d.ts +1 -0
  33. package/build/index.flow.js +394 -0
  34. package/build/index.js +2 -1
  35. package/build/index.js.map +1 -0
  36. package/build/matches.d.ts +9 -0
  37. package/build/matches.js +3 -2
  38. package/build/matches.js.map +1 -0
  39. package/build/{pure.js.flow → pure.d.ts} +5 -8
  40. package/build/pure.js +14 -31
  41. package/build/pure.js.map +1 -0
  42. package/build/queries/a11yAPI.d.ts +66 -0
  43. package/build/{helpers → queries}/a11yAPI.js +16 -15
  44. package/build/queries/a11yAPI.js.map +1 -0
  45. package/build/queries/displayValue.d.ts +13 -0
  46. package/build/{helpers/byDisplayValue.js → queries/displayValue.js} +23 -17
  47. package/build/queries/displayValue.js.map +1 -0
  48. package/build/queries/makeA11yQuery.d.ts +13 -0
  49. package/build/{helpers → queries}/makeA11yQuery.js +3 -2
  50. package/build/queries/makeA11yQuery.js.map +1 -0
  51. package/build/queries/makeQueries.d.ts +19 -0
  52. package/build/{helpers → queries}/makeQueries.js +23 -19
  53. package/build/queries/makeQueries.js.map +1 -0
  54. package/build/queries/placeholderText.d.ts +13 -0
  55. package/build/{helpers/byPlaceholderText.js → queries/placeholderText.js} +23 -17
  56. package/build/queries/placeholderText.js.map +1 -0
  57. package/build/queries/testId.d.ts +13 -0
  58. package/build/{helpers/byTestId.js → queries/testId.js} +19 -13
  59. package/build/queries/testId.js.map +1 -0
  60. package/build/queries/text.d.ts +17 -0
  61. package/build/{helpers/byText.js → queries/text.js} +27 -21
  62. package/build/queries/text.js.map +1 -0
  63. package/build/queries/unsafeProps.d.ts +16 -0
  64. package/build/queries/unsafeProps.js +58 -0
  65. package/build/queries/unsafeProps.js.map +1 -0
  66. package/build/queries/unsafeType.d.ts +9 -0
  67. package/build/queries/unsafeType.js +54 -0
  68. package/build/queries/unsafeType.js.map +1 -0
  69. package/build/render.d.ts +135 -0
  70. package/build/render.js +16 -21
  71. package/build/render.js.map +1 -0
  72. package/build/renderHook.d.ts +17 -0
  73. package/build/renderHook.js +57 -0
  74. package/build/renderHook.js.map +1 -0
  75. package/build/shallow.d.ts +8 -0
  76. package/build/shallow.js +3 -9
  77. package/build/shallow.js.map +1 -0
  78. package/build/waitFor.d.ts +8 -0
  79. package/build/waitFor.js +26 -22
  80. package/build/waitFor.js.map +1 -0
  81. package/build/waitForElementToBeRemoved.d.ts +2 -0
  82. package/build/waitForElementToBeRemoved.js +2 -1
  83. package/build/waitForElementToBeRemoved.js.map +1 -0
  84. package/build/within.d.ts +117 -0
  85. package/build/within.js +19 -9
  86. package/build/within.js.map +1 -0
  87. package/package.json +24 -14
  88. package/typings/index.flow.js +394 -0
  89. package/build/act.js.flow +0 -9
  90. package/build/cleanup.js.flow +0 -13
  91. package/build/fireEvent.js.flow +0 -127
  92. package/build/flushMicroTasks.js.flow +0 -23
  93. package/build/helpers/a11yAPI.js.flow +0 -241
  94. package/build/helpers/byDisplayValue.js.flow +0 -66
  95. package/build/helpers/byPlaceholderText.js.flow +0 -62
  96. package/build/helpers/byTestId.js.flow +0 -50
  97. package/build/helpers/byText.js.flow +0 -108
  98. package/build/helpers/debugDeep.js.flow +0 -16
  99. package/build/helpers/debugShallow.js.flow +0 -20
  100. package/build/helpers/errors.js.flow +0 -82
  101. package/build/helpers/filterNodeByType.js.flow +0 -1
  102. package/build/helpers/findByAPI.js +0 -32
  103. package/build/helpers/findByAPI.js.flow +0 -76
  104. package/build/helpers/format.js.flow +0 -10
  105. package/build/helpers/getByAPI.js +0 -98
  106. package/build/helpers/getByAPI.js.flow +0 -157
  107. package/build/helpers/makeA11yQuery.js.flow +0 -98
  108. package/build/helpers/makeQueries.js.flow +0 -165
  109. package/build/helpers/queryByAPI.js +0 -92
  110. package/build/helpers/queryByAPI.js.flow +0 -166
  111. package/build/helpers/timers.js.flow +0 -88
  112. package/build/index.js.flow +0 -18
  113. package/build/matches.js.flow +0 -41
  114. package/build/render.js.flow +0 -109
  115. package/build/shallow.js.flow +0 -26
  116. package/build/types.flow.js +0 -1
  117. package/build/types.flow.js.flow +0 -59
  118. package/build/waitFor.js.flow +0 -226
  119. package/build/waitForElementToBeRemoved.js.flow +0 -42
  120. package/build/within.js.flow +0 -18
  121. package/typings/index.d.ts +0 -433
@@ -0,0 +1,8 @@
1
+ import { ErrorWithStack } from './helpers/errors';
2
+ export declare type WaitForOptions = {
3
+ timeout?: number;
4
+ interval?: number;
5
+ stackTraceError?: ErrorWithStack;
6
+ onTimeout?: (error: unknown) => Error;
7
+ };
8
+ export default function waitFor<T>(expectation: () => T, options?: WaitForOptions): Promise<T>;
package/build/waitFor.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = waitFor;
7
- exports.waitForElement = waitForElement;
8
7
 
9
8
  var React = _interopRequireWildcard(require("react"));
10
9
 
@@ -16,9 +15,9 @@ var _timers = require("./helpers/timers");
16
15
 
17
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
17
 
19
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
19
 
21
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
21
 
23
22
  /* globals jest */
24
23
  const DEFAULT_TIMEOUT = 1000;
@@ -99,7 +98,7 @@ function waitForInternal(expectation, {
99
98
  checkExpectation();
100
99
  }
101
100
 
102
- function onDone(error, result) {
101
+ function onDone(done) {
103
102
  finished = true;
104
103
  (0, _timers.clearTimeout)(overallTimeoutTimer);
105
104
 
@@ -107,11 +106,10 @@ function waitForInternal(expectation, {
107
106
  clearInterval(intervalId);
108
107
  }
109
108
 
110
- if (error) {
111
- reject(error);
109
+ if (done.type === 'error') {
110
+ reject(done.error);
112
111
  } else {
113
- // $FlowIgnore[incompatible-return] error and result are mutually exclusive
114
- resolve(result);
112
+ resolve(done.result);
115
113
  }
116
114
  }
117
115
 
@@ -133,14 +131,19 @@ function waitForInternal(expectation, {
133
131
  if (promiseStatus === 'pending') return;
134
132
 
135
133
  try {
136
- const result = expectation(); // $FlowIgnore[incompatible-type]
134
+ const result = expectation(); // @ts-ignore result can be a promise
135
+ // eslint-disable-next-line promise/prefer-await-to-then
137
136
 
138
137
  if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
139
- promiseStatus = 'pending'; // eslint-disable-next-line promise/catch-or-return
138
+ const promiseResult = result;
139
+ promiseStatus = 'pending'; // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then
140
140
 
141
- result.then(resolvedValue => {
141
+ promiseResult.then(resolvedValue => {
142
142
  promiseStatus = 'resolved';
143
- onDone(null, resolvedValue);
143
+ onDone({
144
+ type: 'result',
145
+ result: resolvedValue
146
+ });
144
147
  return;
145
148
  }, rejectedValue => {
146
149
  promiseStatus = 'rejected';
@@ -148,7 +151,10 @@ function waitForInternal(expectation, {
148
151
  return;
149
152
  });
150
153
  } else {
151
- onDone(null, result);
154
+ onDone({
155
+ type: 'result',
156
+ result: result
157
+ });
152
158
  } // If `callback` throws, wait for the next mutation, interval, or timeout.
153
159
 
154
160
  } catch (error) {
@@ -178,7 +184,10 @@ function waitForInternal(expectation, {
178
184
  onTimeout(error);
179
185
  }
180
186
 
181
- onDone(error, null);
187
+ onDone({
188
+ type: 'error',
189
+ error
190
+ });
182
191
  }
183
192
  });
184
193
  }
@@ -195,16 +204,11 @@ async function waitFor(expectation, options) {
195
204
  return waitForInternal(expectation, optionsWithStackTrace);
196
205
  }
197
206
 
198
- let result; //$FlowFixMe: `act` has incorrect flow typing
199
-
207
+ let result;
200
208
  await (0, _act.default)(async () => {
201
209
  result = await waitForInternal(expectation, optionsWithStackTrace);
202
- }); //$FlowFixMe: either we have result or `waitFor` threw error
210
+ }); // Either we have result or `waitFor` threw error
203
211
 
204
212
  return result;
205
213
  }
206
-
207
- function waitForElement(expectation, _timeout = 4500, _interval = 50) {
208
- (0, _errors.throwRemovedFunctionError)('waitForElement', 'migration-v2#waitfor-api-changes');
209
- return Promise.reject();
210
- }
214
+ //# sourceMappingURL=waitFor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/waitFor.ts"],"names":["DEFAULT_TIMEOUT","DEFAULT_INTERVAL","checkReactVersionAtLeast","major","minor","React","version","undefined","actualMajor","actualMinor","split","map","Number","waitForInternal","expectation","timeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","handleTimeout","usingFakeTimers","checkExpectation","fakeTimeRemaining","error","Error","jest","advanceTimersByTime","setInterval","checkRealTimersCallback","onDone","done","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","waitFor","options","ErrorWithStack","optionsWithStackTrace"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAJA;AAWA,MAAMA,eAAe,GAAG,IAAxB;AACA,MAA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AAI,EAAE,OAAR;AAAiBT,QAAAA;AAAjB,OAAD,CAAN;AACD;AACF,GA/IM,CAAP;AAgJD;;AAEc,eAAee,OAAf,CACbjC,WADa,EAEbkC,OAFa,EAGD;AACZ;AACA,QAAM/B,eAAe,GAAG,IAAIgC,sBAAJ,CAAmB,mBAAnB,EAAwCF,OAAxC,CAAxB;AACA,QAAMG,qBAAqB,GAAG;AAAEjC,IAAAA,eAAF;AAAmB,OAAG+B;AAAtB,GAA9B;;AAEA,MAAI,CAAC9C,wBAAwB,CAAC,EAAD,EAAK,CAAL,CAA7B,EAAsC;AACpC,WAAOW,eAAe,CAACC,WAAD,EAAcoC,qBAAd,CAAtB;AACD;;AAED,MAAIR,MAAJ;AAEA,QAAM,kBAAI,YAAY;AACpBA,IAAAA,MAAM,GAAG,MAAM7B,eAAe,CAACC,WAAD,EAAcoC,qBAAd,CAA9B;AACD,GAFK,CAAN,CAXY,CAeZ;;AACA,SAAOR,MAAP;AACD","sourcesContent":["/* globals jest */\nimport * as React from 'react';\nimport act from './act';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n setImmediate,\n jestFakeTimersAreEnabled,\n} from './helpers/timers';\n\nconst DEFAULT_TIMEOUT = 1000;\nconst DEFAULT_INTERVAL = 50;\n\nfunction checkReactVersionAtLeast(major: number, minor: number): boolean {\n if (React.version === undefined) return false;\n const [actualMajor, actualMinor] = React.version.split('.').map(Number);\n\n return actualMajor > major || (actualMajor === major && actualMinor >= minor);\n}\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n stackTraceError?: ErrorWithStack;\n onTimeout?: (error: unknown) => Error;\n};\n\nfunction waitForInternal<T>(\n expectation: () => T,\n {\n timeout = DEFAULT_TIMEOUT,\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 const overallTimeoutTimer = setTimeout(handleTimeout, timeout);\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 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 new Promise((resolve) => setImmediate(resolve));\n }\n } else {\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 clearTimeout(overallTimeoutTimer);\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;\n if (lastError) {\n error = lastError;\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 onTimeout(error);\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(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"],"file":"waitFor.js"}
@@ -0,0 +1,2 @@
1
+ import type { WaitForOptions } from './waitFor';
2
+ export default function waitForElementToBeRemoved<T>(expectation: () => T, options?: WaitForOptions): Promise<T>;
@@ -40,4 +40,5 @@ async function waitForElementToBeRemoved(expectation, options) {
40
40
 
41
41
  return initialElements;
42
42
  }, options);
43
- }
43
+ }
44
+ //# sourceMappingURL=waitForElementToBeRemoved.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/waitForElementToBeRemoved.ts"],"names":["isRemoved","result","Array","isArray","length","waitForElementToBeRemoved","expectation","options","timeoutError","ErrorWithStack","initialElements","error"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEA,SAASA,SAAT,CAAsBC,MAAtB,EAA0C;AACxC,SAAO,CAACA,MAAD,IAAYC,KAAK,CAACC,OAAN,CAAcF,MAAd,KAAyB,CAACA,MAAM,CAACG,MAApD;AACD;;AAEc,eAAeC,yBAAf,CACbC,WADa,EAEbC,OAFa,EAGD;AACZ;AACA,QAAMC,YAAY,GAAG,IAAIC,sBAAJ,CACnB,yCADmB,EAEnBJ,yBAFmB,CAArB,CAFY,CAOZ;;AACA,QAAMK,eAAe,GAAGJ,WAAW,EAAnC;;AACA,MAAIN,SAAS,CAACU,eAAD,CAAb,EAAgC;AAC9B,UAAM,IAAID,sBAAJ,CACJ,oKADI,EAEJJ,yBAFI,CAAN;AAID;;AAED,SAAO,sBAAQ,MAAM;AACnB,QAAIJ,MAAJ;;AACA,QAAI;AACFA,MAAAA,MAAM,GAAGK,WAAW,EAApB;AACD,KAFD,CAEE,OAAOK,KAAP,EAAc;AACd,aAAOD,eAAP;AACD;;AAED,QAAI,CAACV,SAAS,CAACC,MAAD,CAAd,EAAwB;AACtB,YAAMO,YAAN;AACD;;AAED,WAAOE,eAAP;AACD,GAbM,EAaJH,OAbI,CAAP;AAcD","sourcesContent":["import waitFor from './waitFor';\nimport type { WaitForOptions } from './waitFor';\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 waitFor(() => {\n let result;\n try {\n result = expectation();\n } catch (error) {\n return initialElements;\n }\n\n if (!isRemoved(result)) {\n throw timeoutError;\n }\n\n return initialElements;\n }, options);\n}\n"],"file":"waitForElementToBeRemoved.js"}
@@ -0,0 +1,117 @@
1
+ /// <reference types="react" />
2
+ import type { ReactTestInstance } from 'react-test-renderer';
3
+ export declare function within(instance: ReactTestInstance): {
4
+ getByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance;
5
+ getAllByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance[];
6
+ queryByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance | null;
7
+ queryAllByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance[];
8
+ findByLabelText: (label: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
9
+ findAllByLabelText: (label: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
10
+ getByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance;
11
+ getByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance;
12
+ getAllByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
13
+ getAllByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
14
+ queryByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance | null;
15
+ queryByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance | null;
16
+ queryAllByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
17
+ queryAllByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
18
+ findByA11yHint: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
19
+ findByHintText: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
20
+ findAllByA11yHint: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
21
+ findAllByHintText: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
22
+ getByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance;
23
+ getAllByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance[];
24
+ queryByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance | null;
25
+ queryAllByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance[];
26
+ findByRole: (role: import("react-native").AccessibilityRole, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
27
+ findAllByRole: (role: import("react-native").AccessibilityRole, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
28
+ getByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance;
29
+ getAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance[];
30
+ queryByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance | null;
31
+ queryAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance[];
32
+ findByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
33
+ findAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
34
+ getByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance;
35
+ getAllByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance[];
36
+ queryByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance | null;
37
+ queryAllByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance[];
38
+ findByA11yState: (accessibilityState: import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
39
+ findAllByA11yState: (accessibilityState: import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
40
+ getByA11yValue: (a11yValue: {
41
+ min?: number | undefined;
42
+ max?: number | undefined;
43
+ now?: number | undefined;
44
+ text?: string | undefined;
45
+ }) => ReactTestInstance;
46
+ getAllByA11yValue: (a11yValue: {
47
+ min?: number | undefined;
48
+ max?: number | undefined;
49
+ now?: number | undefined;
50
+ text?: string | undefined;
51
+ }) => ReactTestInstance[];
52
+ queryByA11yValue: (a11yValue: {
53
+ min?: number | undefined;
54
+ max?: number | undefined;
55
+ now?: number | undefined;
56
+ text?: string | undefined;
57
+ }) => ReactTestInstance | null;
58
+ queryAllByA11yValue: (a11yValue: {
59
+ min?: number | undefined;
60
+ max?: number | undefined;
61
+ now?: number | undefined;
62
+ text?: string | undefined;
63
+ }) => ReactTestInstance[];
64
+ findByA11yValue: (a11yValue: {
65
+ min?: number | undefined;
66
+ max?: number | undefined;
67
+ now?: number | undefined;
68
+ text?: string | undefined;
69
+ }, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
70
+ findAllByA11yValue: (a11yValue: {
71
+ min?: number | undefined;
72
+ max?: number | undefined;
73
+ now?: number | undefined;
74
+ text?: string | undefined;
75
+ }, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
76
+ UNSAFE_getByProps: (props: {
77
+ [key: string]: any;
78
+ }) => ReactTestInstance;
79
+ UNSAFE_getAllByProps: (props: {
80
+ [key: string]: any;
81
+ }) => ReactTestInstance[];
82
+ UNSAFE_queryByProps: (props: {
83
+ [key: string]: any;
84
+ }) => ReactTestInstance | null;
85
+ UNSAFE_queryAllByProps: (props: {
86
+ [key: string]: any;
87
+ }) => ReactTestInstance[];
88
+ UNSAFE_getByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance;
89
+ UNSAFE_getAllByType: <P_1>(type: import("react").ComponentType<P_1>) => ReactTestInstance[];
90
+ UNSAFE_queryByType: <P_2>(type: import("react").ComponentType<P_2>) => ReactTestInstance | null;
91
+ UNSAFE_queryAllByType: <P_3>(type: import("react").ComponentType<P_3>) => ReactTestInstance[];
92
+ getByPlaceholderText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
93
+ getAllByPlaceholderText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
94
+ queryByPlaceholderText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
95
+ queryAllByPlaceholderText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
96
+ findByPlaceholderText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
97
+ findAllByPlaceholderText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
98
+ getByDisplayValue: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
99
+ getAllByDisplayValue: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
100
+ queryByDisplayValue: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
101
+ queryAllByDisplayValue: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
102
+ findByDisplayValue: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
103
+ findAllByDisplayValue: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
104
+ getByTestId: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
105
+ getAllByTestId: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
106
+ queryByTestId: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
107
+ queryAllByTestId: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
108
+ findByTestId: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
109
+ findAllByTestId: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
110
+ getByText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
111
+ getAllByText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
112
+ queryByText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
113
+ queryAllByText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
114
+ findByText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
115
+ findAllByText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
116
+ };
117
+ export declare const getQueriesForElement: typeof within;
package/build/within.js CHANGED
@@ -3,24 +3,34 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.within = within;
7
6
  exports.getQueriesForElement = void 0;
7
+ exports.within = within;
8
+
9
+ var _a11yAPI = require("./queries/a11yAPI");
10
+
11
+ var _text = require("./queries/text");
12
+
13
+ var _testId = require("./queries/testId");
8
14
 
9
- var _getByAPI = require("./helpers/getByAPI");
15
+ var _displayValue = require("./queries/displayValue");
10
16
 
11
- var _queryByAPI = require("./helpers/queryByAPI");
17
+ var _placeholderText = require("./queries/placeholderText");
12
18
 
13
- var _findByAPI = require("./helpers/findByAPI");
19
+ var _unsafeType = require("./queries/unsafeType");
14
20
 
15
- var _a11yAPI = require("./helpers/a11yAPI");
21
+ var _unsafeProps = require("./queries/unsafeProps");
16
22
 
17
23
  function within(instance) {
18
- return { ...(0, _getByAPI.getByAPI)(instance),
19
- ...(0, _queryByAPI.queryByAPI)(instance),
20
- ...(0, _findByAPI.findByAPI)(instance),
24
+ return { ...(0, _text.bindByTextQueries)(instance),
25
+ ...(0, _testId.bindByTestIdQueries)(instance),
26
+ ...(0, _displayValue.bindByDisplayValueQueries)(instance),
27
+ ...(0, _placeholderText.bindByPlaceholderTextQueries)(instance),
28
+ ...(0, _unsafeType.bindUnsafeByTypeQueries)(instance),
29
+ ...(0, _unsafeProps.bindUnsafeByPropsQueries)(instance),
21
30
  ...(0, _a11yAPI.a11yAPI)(instance)
22
31
  };
23
32
  }
24
33
 
25
34
  const getQueriesForElement = within;
26
- exports.getQueriesForElement = getQueriesForElement;
35
+ exports.getQueriesForElement = getQueriesForElement;
36
+ //# sourceMappingURL=within.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/within.ts"],"names":["within","instance","getQueriesForElement"],"mappings":";;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,SAASA,MAAT,CAAgBC,QAAhB,EAA6C;AAClD,SAAO,EACL,GAAG,6BAAkBA,QAAlB,CADE;AAEL,OAAG,iCAAoBA,QAApB,CAFE;AAGL,OAAG,6CAA0BA,QAA1B,CAHE;AAIL,OAAG,mDAA6BA,QAA7B,CAJE;AAKL,OAAG,yCAAwBA,QAAxB,CALE;AAML,OAAG,2CAAyBA,QAAzB,CANE;AAOL,OAAG,sBAAQA,QAAR;AAPE,GAAP;AASD;;AAEM,MAAMC,oBAAoB,GAAGF,MAA7B","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { a11yAPI } from './queries/a11yAPI';\nimport { bindByTextQueries } from './queries/text';\nimport { bindByTestIdQueries } from './queries/testId';\nimport { bindByDisplayValueQueries } from './queries/displayValue';\nimport { bindByPlaceholderTextQueries } from './queries/placeholderText';\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 ...bindUnsafeByTypeQueries(instance),\n ...bindUnsafeByPropsQueries(instance),\n ...a11yAPI(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"file":"within.js"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "9.1.0",
3
+ "version": "10.0.1",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
- "typings": "./typings/index.d.ts",
6
+ "types": "build/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://www.github.com/callstack/react-native-testing-library.git"
@@ -21,7 +21,7 @@
21
21
  "files": [
22
22
  "build/",
23
23
  "jest-preset/",
24
- "typings/index.d.ts",
24
+ "typings/index.flow.js",
25
25
  "pure.js",
26
26
  "dont-cleanup-after-each.js"
27
27
  ],
@@ -29,18 +29,23 @@
29
29
  "@babel/cli": "^7.8.4",
30
30
  "@babel/core": "^7.9.0",
31
31
  "@babel/plugin-proposal-class-properties": "^7.8.3",
32
+ "@babel/plugin-transform-flow-strip-types": "^7.16.0",
32
33
  "@babel/preset-env": "^7.9.6",
33
34
  "@babel/preset-flow": "^7.9.0",
34
35
  "@babel/preset-react": "^7.9.4",
36
+ "@babel/preset-typescript": "^7.16.0",
35
37
  "@callstack/eslint-config": "^11.0.0",
36
38
  "@release-it/conventional-changelog": "^2.0.0",
37
39
  "@testing-library/jest-native": "~4.0.2",
40
+ "@types/jest": "^27.0.0",
38
41
  "@types/react": "^17.0.0",
39
- "@types/react-native": "^0.66.5",
42
+ "@types/react-native": "^0.66.6",
40
43
  "@types/react-test-renderer": "^17.0.0",
41
44
  "babel-jest": "^27.0.0",
42
45
  "conventional-changelog-cli": "^2.0.11",
46
+ "cp-cli": "^2.0.0",
43
47
  "dedent": "^0.7.0",
48
+ "del-cli": "^3.0.1",
44
49
  "eslint": "^7.0.0",
45
50
  "flow-bin": "^0.141.0",
46
51
  "flow-copy-source": "^2.0.9",
@@ -61,25 +66,30 @@
61
66
  "react-test-renderer": ">=16.0.0"
62
67
  },
63
68
  "scripts": {
69
+ "clean": "del build",
64
70
  "test": "jest",
65
- "flow-check": "flow check",
66
- "typescript-check": "tsc --noEmit --skipLibCheck --jsx react ./typings/__tests__/*",
71
+ "typecheck": "tsc",
72
+ "flow": "flow",
73
+ "copy-flowtypes": "cp typings/index.flow.js build",
67
74
  "lint": "eslint src --cache",
68
75
  "release": "release-it",
69
- "prepublish": "yarn build && yarn copy-flowtypes",
70
- "copy-flowtypes": "flow-copy-source --ignore __tests__/*.js src build",
71
- "build": "rm -rf build; babel src --out-dir build --ignore 'src/__tests__/*'"
76
+ "prepublish": "yarn build",
77
+ "build:js": "babel src --out-dir build --extensions \".js,.ts,.jsx,.tsx\" --source-maps --ignore \"**/__tests__/**\"",
78
+ "build:js:watch": "yarn build:js --watch",
79
+ "build:ts": "tsc --build tsconfig.release.json",
80
+ "build:ts:watch": "yarn build:ts --watch --preserveWatchOutput",
81
+ "build": "yarn clean && yarn build:js && yarn build:ts && yarn copy-flowtypes",
82
+ "prepare": "yarn build"
72
83
  },
73
84
  "jest": {
74
85
  "preset": "../jest-preset",
75
- "moduleFileExtensions": [
76
- "js",
77
- "json"
78
- ],
79
86
  "rootDir": "./src",
80
87
  "testPathIgnorePatterns": [
81
88
  "timerUtils"
82
89
  ],
83
- "testTimeout": 30000
90
+ "testTimeout": 30000,
91
+ "transformIgnorePatterns": [
92
+ "/node_modules/(?!(@react-native|react-native)/).*/"
93
+ ]
84
94
  }
85
95
  }