@testing-library/react-native 11.2.0 → 11.4.0

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 (100) hide show
  1. package/README.md +3 -0
  2. package/build/act.js +9 -15
  3. package/build/act.js.map +1 -1
  4. package/build/cleanup.js +0 -4
  5. package/build/cleanup.js.map +1 -1
  6. package/build/config.d.ts +15 -0
  7. package/build/config.js +27 -0
  8. package/build/config.js.map +1 -0
  9. package/build/fireEvent.js +3 -33
  10. package/build/fireEvent.js.map +1 -1
  11. package/build/flushMicroTasks.js +0 -3
  12. package/build/flushMicroTasks.js.map +1 -1
  13. package/build/helpers/accessiblity.d.ts +3 -0
  14. package/build/helpers/accessiblity.js +14 -20
  15. package/build/helpers/accessiblity.js.map +1 -1
  16. package/build/helpers/component-tree.d.ts +15 -0
  17. package/build/helpers/component-tree.js +49 -15
  18. package/build/helpers/component-tree.js.map +1 -1
  19. package/build/helpers/debugDeep.d.ts +5 -1
  20. package/build/helpers/debugDeep.js +7 -6
  21. package/build/helpers/debugDeep.js.map +1 -1
  22. package/build/helpers/debugShallow.js +0 -5
  23. package/build/helpers/debugShallow.js.map +1 -1
  24. package/build/helpers/errors.js +4 -25
  25. package/build/helpers/errors.js.map +1 -1
  26. package/build/helpers/filterNodeByType.js +0 -2
  27. package/build/helpers/filterNodeByType.js.map +1 -1
  28. package/build/helpers/format.d.ts +5 -1
  29. package/build/helpers/format.js +17 -7
  30. package/build/helpers/format.js.map +1 -1
  31. package/build/helpers/matchers/accessibilityState.d.ts +3 -0
  32. package/build/helpers/matchers/accessibilityState.js +28 -0
  33. package/build/helpers/matchers/accessibilityState.js.map +1 -0
  34. package/build/helpers/matchers/matchArrayProp.js +0 -3
  35. package/build/helpers/matchers/matchArrayProp.js.map +1 -1
  36. package/build/helpers/matchers/matchObjectProp.js +0 -2
  37. package/build/helpers/matchers/matchObjectProp.js.map +1 -1
  38. package/build/helpers/matchers/matchStringProp.js +0 -3
  39. package/build/helpers/matchers/matchStringProp.js.map +1 -1
  40. package/build/helpers/stringValidation.js +0 -7
  41. package/build/helpers/stringValidation.js.map +1 -1
  42. package/build/helpers/timers.js +11 -22
  43. package/build/helpers/timers.js.map +1 -1
  44. package/build/index.flow.js +74 -21
  45. package/build/index.js +0 -6
  46. package/build/index.js.map +1 -1
  47. package/build/matches.js +2 -4
  48. package/build/matches.js.map +1 -1
  49. package/build/pure.d.ts +2 -0
  50. package/build/pure.js +13 -12
  51. package/build/pure.js.map +1 -1
  52. package/build/queries/a11yState.d.ts +1 -1
  53. package/build/queries/a11yState.js +15 -13
  54. package/build/queries/a11yState.js.map +1 -1
  55. package/build/queries/a11yValue.js +0 -8
  56. package/build/queries/a11yValue.js.map +1 -1
  57. package/build/queries/displayValue.js +7 -26
  58. package/build/queries/displayValue.js.map +1 -1
  59. package/build/queries/hintText.d.ts +19 -18
  60. package/build/queries/hintText.js +10 -11
  61. package/build/queries/hintText.js.map +1 -1
  62. package/build/queries/labelText.d.ts +7 -6
  63. package/build/queries/labelText.js +10 -11
  64. package/build/queries/labelText.js.map +1 -1
  65. package/build/queries/makeQueries.d.ts +3 -3
  66. package/build/queries/makeQueries.js +40 -24
  67. package/build/queries/makeQueries.js.map +1 -1
  68. package/build/queries/placeholderText.js +6 -25
  69. package/build/queries/placeholderText.js.map +1 -1
  70. package/build/queries/role.d.ts +3 -2
  71. package/build/queries/role.js +23 -13
  72. package/build/queries/role.js.map +1 -1
  73. package/build/queries/testId.js +0 -9
  74. package/build/queries/testId.js.map +1 -1
  75. package/build/queries/text.js +21 -45
  76. package/build/queries/text.js.map +1 -1
  77. package/build/queries/unsafeProps.js +2 -11
  78. package/build/queries/unsafeProps.js.map +1 -1
  79. package/build/queries/unsafeType.js +2 -9
  80. package/build/queries/unsafeType.js.map +1 -1
  81. package/build/react-versions.js +0 -4
  82. package/build/react-versions.js.map +1 -1
  83. package/build/render.d.ts +32 -31
  84. package/build/render.js +21 -31
  85. package/build/render.js.map +1 -1
  86. package/build/renderHook.js +2 -12
  87. package/build/renderHook.js.map +1 -1
  88. package/build/screen.js +0 -6
  89. package/build/screen.js.map +1 -1
  90. package/build/shallow.js +0 -6
  91. package/build/shallow.js.map +1 -1
  92. package/build/waitFor.js +31 -53
  93. package/build/waitFor.js.map +1 -1
  94. package/build/waitForElementToBeRemoved.js +2 -11
  95. package/build/waitForElementToBeRemoved.js.map +1 -1
  96. package/build/within.d.ts +30 -30
  97. package/build/within.js +2 -14
  98. package/build/within.js.map +1 -1
  99. package/package.json +18 -17
  100. package/typings/index.flow.js +74 -21
package/build/waitFor.js CHANGED
@@ -4,132 +4,120 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = waitFor;
7
-
8
7
  var _act = _interopRequireWildcard(require("./act"));
9
-
8
+ var _config = require("./config");
10
9
  var _errors = require("./helpers/errors");
11
-
12
10
  var _timers = require("./helpers/timers");
13
-
14
11
  var _reactVersions = require("./react-versions");
15
-
16
12
  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); }
17
-
18
13
  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; }
19
-
20
14
  /* globals jest */
21
- const DEFAULT_TIMEOUT = 1000;
22
- const DEFAULT_INTERVAL = 50;
23
15
 
16
+ const DEFAULT_INTERVAL = 50;
24
17
  function waitForInternal(expectation, {
25
- timeout = DEFAULT_TIMEOUT,
18
+ timeout = (0, _config.getConfig)().asyncUtilTimeout,
26
19
  interval = DEFAULT_INTERVAL,
27
20
  stackTraceError,
28
21
  onTimeout
29
22
  }) {
30
23
  if (typeof expectation !== 'function') {
31
24
  throw new TypeError('Received `expectation` arg must be a function');
32
- } // eslint-disable-next-line no-async-promise-executor
33
-
25
+ }
34
26
 
27
+ // eslint-disable-next-line no-async-promise-executor
35
28
  return new Promise(async (resolve, reject) => {
36
29
  let lastError, intervalId;
37
30
  let finished = false;
38
31
  let promiseStatus = 'idle';
39
- const overallTimeoutTimer = (0, _timers.setTimeout)(handleTimeout, timeout);
32
+ let overallTimeoutTimer = null;
40
33
  const usingFakeTimers = (0, _timers.jestFakeTimersAreEnabled)();
41
-
42
34
  if (usingFakeTimers) {
43
- checkExpectation(); // this is a dangerous rule to disable because it could lead to an
35
+ checkExpectation();
36
+ // this is a dangerous rule to disable because it could lead to an
44
37
  // infinite loop. However, eslint isn't smart enough to know that we're
45
38
  // setting finished inside `onDone` which will be called when we're done
46
39
  // waiting or when we've timed out.
47
40
  // eslint-disable-next-line no-unmodified-loop-condition
48
-
49
41
  let fakeTimeRemaining = timeout;
50
-
51
42
  while (!finished) {
52
43
  if (!(0, _timers.jestFakeTimersAreEnabled)()) {
53
44
  const error = new Error(`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`);
54
-
55
45
  if (stackTraceError) {
56
46
  (0, _errors.copyStackTrace)(error, stackTraceError);
57
47
  }
58
-
59
48
  reject(error);
60
49
  return;
61
- } // when fake timers are used we want to simulate the interval time passing
62
-
50
+ }
63
51
 
52
+ // when fake timers are used we want to simulate the interval time passing
64
53
  if (fakeTimeRemaining <= 0) {
54
+ handleTimeout();
65
55
  return;
66
56
  } else {
67
57
  fakeTimeRemaining -= interval;
68
- } // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
58
+ }
59
+
60
+ // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
69
61
  // possible that could make this loop go on forever if someone is using
70
62
  // third party code that's setting up recursive timers so rapidly that
71
63
  // the user's timer's don't get a chance to resolve. So we'll advance
72
64
  // by an interval instead. (We have a test for this case).
65
+ jest.advanceTimersByTime(interval);
73
66
 
74
-
75
- jest.advanceTimersByTime(interval); // It's really important that checkExpectation is run *before* we flush
67
+ // It's really important that checkExpectation is run *before* we flush
76
68
  // in-flight promises. To be honest, I'm not sure why, and I can't quite
77
69
  // think of a way to reproduce the problem in a test, but I spent
78
70
  // an entire day banging my head against a wall on this.
71
+ checkExpectation();
79
72
 
80
- checkExpectation(); // In this rare case, we *need* to wait for in-flight promises
73
+ // In this rare case, we *need* to wait for in-flight promises
81
74
  // to resolve before continuing. We don't need to take advantage
82
75
  // of parallelization so we're fine.
83
76
  // https://stackoverflow.com/a/59243586/971592
84
77
  // eslint-disable-next-line no-await-in-loop
85
-
86
78
  await new Promise(resolve => (0, _timers.setImmediate)(resolve));
87
79
  }
88
80
  } else {
81
+ overallTimeoutTimer = (0, _timers.setTimeout)(handleTimeout, timeout);
89
82
  intervalId = setInterval(checkRealTimersCallback, interval);
90
83
  checkExpectation();
91
84
  }
92
-
93
85
  function onDone(done) {
94
86
  finished = true;
95
- (0, _timers.clearTimeout)(overallTimeoutTimer);
96
-
87
+ if (overallTimeoutTimer) {
88
+ (0, _timers.clearTimeout)(overallTimeoutTimer);
89
+ }
97
90
  if (!usingFakeTimers) {
98
91
  clearInterval(intervalId);
99
92
  }
100
-
101
93
  if (done.type === 'error') {
102
94
  reject(done.error);
103
95
  } else {
104
96
  resolve(done.result);
105
97
  }
106
98
  }
107
-
108
99
  function checkRealTimersCallback() {
109
100
  if ((0, _timers.jestFakeTimersAreEnabled)()) {
110
101
  const error = new Error(`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`);
111
-
112
102
  if (stackTraceError) {
113
103
  (0, _errors.copyStackTrace)(error, stackTraceError);
114
104
  }
115
-
116
105
  return reject(error);
117
106
  } else {
118
107
  return checkExpectation();
119
108
  }
120
109
  }
121
-
122
110
  function checkExpectation() {
123
111
  if (promiseStatus === 'pending') return;
124
-
125
112
  try {
126
- const result = expectation(); // @ts-ignore result can be a promise
127
- // eslint-disable-next-line promise/prefer-await-to-then
113
+ const result = expectation();
128
114
 
115
+ // @ts-ignore result can be a promise
116
+ // eslint-disable-next-line promise/prefer-await-to-then
129
117
  if (typeof result?.then === 'function') {
130
118
  const promiseResult = result;
131
- promiseStatus = 'pending'; // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then
132
-
119
+ promiseStatus = 'pending';
120
+ // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then
133
121
  promiseResult.then(resolvedValue => {
134
122
  promiseStatus = 'resolved';
135
123
  onDone({
@@ -147,35 +135,29 @@ function waitForInternal(expectation, {
147
135
  type: 'result',
148
136
  result: result
149
137
  });
150
- } // If `callback` throws, wait for the next mutation, interval, or timeout.
151
-
138
+ }
139
+ // If `callback` throws, wait for the next mutation, interval, or timeout.
152
140
  } catch (error) {
153
141
  // Save the most recent callback error to reject the promise with it in the event of a timeout
154
142
  lastError = error;
155
143
  }
156
144
  }
157
-
158
145
  function handleTimeout() {
159
146
  let error;
160
-
161
147
  if (lastError) {
162
148
  error = lastError;
163
-
164
149
  if (stackTraceError) {
165
150
  (0, _errors.copyStackTrace)(error, stackTraceError);
166
151
  }
167
152
  } else {
168
153
  error = new Error('Timed out in waitFor.');
169
-
170
154
  if (stackTraceError) {
171
155
  (0, _errors.copyStackTrace)(error, stackTraceError);
172
156
  }
173
157
  }
174
-
175
158
  if (typeof onTimeout === 'function') {
176
159
  onTimeout(error);
177
160
  }
178
-
179
161
  onDone({
180
162
  type: 'error',
181
163
  error
@@ -183,7 +165,6 @@ function waitForInternal(expectation, {
183
165
  }
184
166
  });
185
167
  }
186
-
187
168
  async function waitFor(expectation, options) {
188
169
  // Being able to display a useful stack trace requires generating it before doing anything async
189
170
  const stackTraceError = new _errors.ErrorWithStack('STACK_TRACE_ERROR', waitFor);
@@ -191,27 +172,24 @@ async function waitFor(expectation, options) {
191
172
  stackTraceError,
192
173
  ...options
193
174
  };
194
-
195
175
  if ((0, _reactVersions.checkReactVersionAtLeast)(18, 0)) {
196
176
  const previousActEnvironment = (0, _act.getIsReactActEnvironment)();
197
177
  (0, _act.setReactActEnvironment)(false);
198
-
199
178
  try {
200
179
  return await waitForInternal(expectation, optionsWithStackTrace);
201
180
  } finally {
202
181
  (0, _act.setReactActEnvironment)(previousActEnvironment);
203
182
  }
204
183
  }
205
-
206
184
  if (!(0, _reactVersions.checkReactVersionAtLeast)(16, 9)) {
207
185
  return waitForInternal(expectation, optionsWithStackTrace);
208
186
  }
209
-
210
187
  let result;
211
188
  await (0, _act.default)(async () => {
212
189
  result = await waitForInternal(expectation, optionsWithStackTrace);
213
- }); // Either we have result or `waitFor` threw error
190
+ });
214
191
 
192
+ // Either we have result or `waitFor` threw error
215
193
  return result;
216
194
  }
217
195
  //# sourceMappingURL=waitFor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"waitFor.js","names":["DEFAULT_TIMEOUT","DEFAULT_INTERVAL","waitForInternal","expectation","timeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","setTimeout","handleTimeout","usingFakeTimers","jestFakeTimersAreEnabled","checkExpectation","fakeTimeRemaining","error","Error","copyStackTrace","jest","advanceTimersByTime","setImmediate","setInterval","checkRealTimersCallback","onDone","done","clearTimeout","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","waitFor","options","ErrorWithStack","optionsWithStackTrace","checkReactVersionAtLeast","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","act"],"sources":["../src/waitFor.ts"],"sourcesContent":["/* globals jest */\nimport act, { setReactActEnvironment, getIsReactActEnvironment } from './act';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n setImmediate,\n jestFakeTimersAreEnabled,\n} from './helpers/timers';\nimport { checkReactVersionAtLeast } from './react-versions';\n\nconst DEFAULT_TIMEOUT = 1000;\nconst DEFAULT_INTERVAL = 50;\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(18, 0)) {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n return await waitForInternal(expectation, optionsWithStackTrace);\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;;AACA;;AACA;;AAMA;;;;;;AATA;AAWA,MAAMA,eAAe,GAAG,IAAxB;AACA,MAAMC,gBAAgB,GAAG,EAAzB;;AASA,SAASC,eAAT,CACEC,WADF,EAEE;EACEC,OAAO,GAAGJ,eADZ;EAEEK,QAAQ,GAAGJ,gBAFb;EAGEK,eAHF;EAIEC;AAJF,CAFF,EAQc;EACZ,IA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AzB,EAA6B,CAA7B,CAAL,EAAsC;IACpC,OAAO3C,eAAe,CAACC,WAAD,EAAcyC,qBAAd,CAAtB;EACD;;EAED,IAAIR,MAAJ;EAEA,MAAM,IAAAa,YAAA,EAAI,YAAY;IACpBb,MAAM,GAAG,MAAMlC,eAAe,CAACC,WAAD,EAAcyC,qBAAd,CAA9B;EACD,CAFK,CAAN,CAtBY,CA0BZ;;EACA,OAAOR,MAAP;AACD"}
1
+ {"version":3,"file":"waitFor.js","names":["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","setImmediate","setTimeout","setInterval","checkRealTimersCallback","onDone","done","clearTimeout","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","waitFor","options","ErrorWithStack","optionsWithStackTrace","checkReactVersionAtLeast","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","act"],"sources":["../src/waitFor.ts"],"sourcesContent":["/* globals jest */\nimport act, { setReactActEnvironment, getIsReactActEnvironment } from './act';\nimport { getConfig } from './config';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n setImmediate,\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: unknown) => 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 new Promise((resolve) => setImmediate(resolve));\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;\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(18, 0)) {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n return await waitForInternal(expectation, optionsWithStackTrace);\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;AACA;AACA;AACA;AAMA;AAA4D;AAAA;AAV5D;;AAYA,MAAMA,gBAAgB,GAAG,EAAE;AAS3B,SAASC,eAAe,CACtBC,WAAoB,EACpB;EACEC,OAAO,GAAG,IAAAC,iBAAS,GAAE,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,GAAE;IAElD,IAAID,eAAe,EAAE;MACnBE,gBAAgB,EAAE;MAClB;MACA;MACA;MACA;MACA;MACA,IAAIC,iBAAiB,GAAGlB,OAAO;MAC/B,OAAO,CAACY,QAAQ,EAAE;QAChB,IAAI,CAAC,IAAAI,gCAAwB,GAAE,EAAE;UAC/B,MAAMG,KAAK,GAAG,IAA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QACnCA,SAAS,CAACc,KAAK,CAAC;MAClB;MACAU,MAAM,CAAC;QAAEI,IAAI,EAAE,OAAO;QAAEd;MAAM,CAAC,CAAC;IAClC;EACF,CAAC,CAAC;AACJ;AAEe,eAAeoB,OAAO,CACnCxC,WAAoB,EACpByC,OAAwB,EACZ;EACZ;EACA,MAAMpC,eAAe,GAAG,IAAIqC,sBAAc,CAAC,mBAAmB,EAAEF,OAAO,CAAC;EACxE,MAAMG,qBAAqB,GAAG;IAAEtC,eAAe;IAAE,GAAGoC;EAAQ,CAAC;EAE7D,IAAI,IAAAG,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE;IACnC,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,GAAE;IACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;IAE7B,IAAI;MACF,OAAO,MAAMhD,eAAe,CAACC,WAAW,EAAE2C,qBAAqB,CAAC;IAClE,CAAC,SAAS;MACR,IAAAI,2BAAsB,EAACF,sBAAsB,CAAC;IAChD;EACF;EAEA,IAAI,CAAC,IAAAD,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE;IACpC,OAAO7C,eAAe,CAACC,WAAW,EAAE2C,qBAAqB,CAAC;EAC5D;EAEA,IAAIR,MAAS;EAEb,MAAM,IAAAa,YAAG,EAAC,YAAY;IACpBb,MAAM,GAAG,MAAMpC,eAAe,CAACC,WAAW,EAAE2C,qBAAqB,CAAC;EACpE,CAAC,CAAC;;EAEF;EACA,OAAOR,MAAM;AACf"}
@@ -4,40 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = waitForElementToBeRemoved;
7
-
8
7
  var _waitFor = _interopRequireDefault(require("./waitFor"));
9
-
10
8
  var _errors = require("./helpers/errors");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  function isRemoved(result) {
15
11
  return !result || Array.isArray(result) && !result.length;
16
12
  }
17
-
18
13
  async function waitForElementToBeRemoved(expectation, options) {
19
14
  // Created here so we get a nice stacktrace
20
- const timeoutError = new _errors.ErrorWithStack('Timed out in waitForElementToBeRemoved.', waitForElementToBeRemoved); // Elements have to be present initally and then removed.
15
+ const timeoutError = new _errors.ErrorWithStack('Timed out in waitForElementToBeRemoved.', waitForElementToBeRemoved);
21
16
 
17
+ // Elements have to be present initally and then removed.
22
18
  const initialElements = expectation();
23
-
24
19
  if (isRemoved(initialElements)) {
25
20
  throw new _errors.ErrorWithStack('The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.', waitForElementToBeRemoved);
26
21
  }
27
-
28
22
  return (0, _waitFor.default)(() => {
29
23
  let result;
30
-
31
24
  try {
32
25
  result = expectation();
33
26
  } catch (error) {
34
27
  return initialElements;
35
28
  }
36
-
37
29
  if (!isRemoved(result)) {
38
30
  throw timeoutError;
39
31
  }
40
-
41
32
  return initialElements;
42
33
  }, options);
43
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"waitForElementToBeRemoved.js","names":["isRemoved","result","Array","isArray","length","waitForElementToBeRemoved","expectation","options","timeoutError","ErrorWithStack","initialElements","waitFor","error"],"sources":["../src/waitForElementToBeRemoved.ts"],"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"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEA,SAASA,SAAT,CAAsBC,MAAtB,EAA0C;EACxC,OAAO,CAACA,MAAD,IAAYC,KAAK,CAACC,OAAN,CAAcF,MAAd,KAAyB,CAACA,MAAM,CAACG,MAApD;AACD;;AAEc,eAAeC,yBAAf,CACbC,WADa,EAEbC,OAFa,EAGD;EACZ;EACA,MAAMC,YAAY,GAAG,IAAIC,sBAAJ,CACnB,yCADmB,EAEnBJ,yBAFmB,CAArB,CAFY,CAOZ;;EACA,MAAMK,eAAe,GAAGJ,WAAW,EAAnC;;EACA,IAAIN,SAAS,CAACU,eAAD,CAAb,EAAgC;IAC9B,MAAM,IAAID,sBAAJ,CACJ,oKADI,EAEJJ,yBAFI,CAAN;EAID;;EAED,OAAO,IAAAM,gBAAA,EAAQ,MAAM;IACnB,IAAIV,MAAJ;;IACA,IAAI;MACFA,MAAM,GAAGK,WAAW,EAApB;IACD,CAFD,CAEE,OAAOM,KAAP,EAAc;MACd,OAAOF,eAAP;IACD;;IAED,IAAI,CAACV,SAAS,CAACC,MAAD,CAAd,EAAwB;MACtB,MAAMO,YAAN;IACD;;IAED,OAAOE,eAAP;EACD,CAbM,EAaJH,OAbI,CAAP;AAcD"}
1
+ {"version":3,"file":"waitForElementToBeRemoved.js","names":["isRemoved","result","Array","isArray","length","waitForElementToBeRemoved","expectation","options","timeoutError","ErrorWithStack","initialElements","waitFor","error"],"sources":["../src/waitForElementToBeRemoved.ts"],"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"],"mappings":";;;;;;AAAA;AAEA;AAAkD;AAElD,SAASA,SAAS,CAAIC,MAAS,EAAW;EACxC,OAAO,CAACA,MAAM,IAAKC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAI,CAACA,MAAM,CAACG,MAAO;AAC7D;AAEe,eAAeC,yBAAyB,CACrDC,WAAoB,EACpBC,OAAwB,EACZ;EACZ;EACA,MAAMC,YAAY,GAAG,IAAIC,sBAAc,CACrC,yCAAyC,EACzCJ,yBAAyB,CAC1B;;EAED;EACA,MAAMK,eAAe,GAAGJ,WAAW,EAAE;EACrC,IAAIN,SAAS,CAACU,eAAe,CAAC,EAAE;IAC9B,MAAM,IAAID,sBAAc,CACtB,oKAAoK,EACpKJ,yBAAyB,CAC1B;EACH;EAEA,OAAO,IAAAM,gBAAO,EAAC,MAAM;IACnB,IAAIV,MAAM;IACV,IAAI;MACFA,MAAM,GAAGK,WAAW,EAAE;IACxB,CAAC,CAAC,OAAOM,KAAK,EAAE;MACd,OAAOF,eAAe;IACxB;IAEA,IAAI,CAACV,SAAS,CAACC,MAAM,CAAC,EAAE;MACtB,MAAMO,YAAY;IACpB;IAEA,OAAOE,eAAe;EACxB,CAAC,EAAEH,OAAO,CAAC;AACb"}
package/build/within.d.ts CHANGED
@@ -103,46 +103,46 @@ export declare function within(instance: ReactTestInstance): {
103
103
  findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, void>;
104
104
  getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, {
105
105
  name?: import("./matches").TextMatch | undefined;
106
- }>;
106
+ } & import("react-native").AccessibilityState>;
107
107
  getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, {
108
108
  name?: import("./matches").TextMatch | undefined;
109
- }>;
109
+ } & import("react-native").AccessibilityState>;
110
110
  queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, {
111
111
  name?: import("./matches").TextMatch | undefined;
112
- }>;
112
+ } & import("react-native").AccessibilityState>;
113
113
  queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, {
114
114
  name?: import("./matches").TextMatch | undefined;
115
- }>;
115
+ } & import("react-native").AccessibilityState>;
116
116
  findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, {
117
117
  name?: import("./matches").TextMatch | undefined;
118
- }>;
118
+ } & import("react-native").AccessibilityState>;
119
119
  findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, {
120
120
  name?: import("./matches").TextMatch | undefined;
121
- }>;
122
- getByHintText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
123
- getAllByHintText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
124
- queryByHintText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
125
- queryAllByHintText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
126
- findByHintText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
127
- findAllByHintText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
128
- getByA11yHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
129
- getAllByA11yHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
130
- queryByA11yHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
131
- queryAllByA11yHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
132
- findByA11yHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
133
- findAllByA11yHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
134
- getByAccessibilityHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
135
- getAllByAccessibilityHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
136
- queryByAccessibilityHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
137
- queryAllByAccessibilityHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
138
- findByAccessibilityHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
139
- findAllByAccessibilityHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
140
- getByLabelText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
141
- getAllByLabelText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
142
- queryByLabelText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
143
- queryAllByLabelText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
144
- findByLabelText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
145
- findAllByLabelText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
121
+ } & import("react-native").AccessibilityState>;
122
+ getByHintText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
123
+ getAllByHintText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
124
+ queryByHintText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
125
+ queryAllByHintText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
126
+ findByHintText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
127
+ findAllByHintText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
128
+ getByA11yHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
129
+ getAllByA11yHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
130
+ queryByA11yHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
131
+ queryAllByA11yHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
132
+ findByA11yHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
133
+ findAllByA11yHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
134
+ getByAccessibilityHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
135
+ getAllByAccessibilityHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
136
+ queryByAccessibilityHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
137
+ queryAllByAccessibilityHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
138
+ findByAccessibilityHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
139
+ findAllByAccessibilityHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
140
+ getByLabelText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
141
+ getAllByLabelText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
142
+ queryByLabelText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
143
+ queryAllByLabelText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
144
+ findByLabelText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
145
+ findAllByLabelText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
146
146
  getByPlaceholderText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
147
147
  getAllByPlaceholderText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
148
148
  queryByPlaceholderText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
package/build/within.js CHANGED
@@ -5,31 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getQueriesForElement = void 0;
7
7
  exports.within = within;
8
-
9
8
  var _text = require("./queries/text");
10
-
11
9
  var _testId = require("./queries/testId");
12
-
13
10
  var _displayValue = require("./queries/displayValue");
14
-
15
11
  var _placeholderText = require("./queries/placeholderText");
16
-
17
12
  var _labelText = require("./queries/labelText");
18
-
19
13
  var _hintText = require("./queries/hintText");
20
-
21
14
  var _role = require("./queries/role");
22
-
23
15
  var _a11yState = require("./queries/a11yState");
24
-
25
16
  var _a11yValue = require("./queries/a11yValue");
26
-
27
17
  var _unsafeType = require("./queries/unsafeType");
28
-
29
18
  var _unsafeProps = require("./queries/unsafeProps");
30
-
31
19
  function within(instance) {
32
- return { ...(0, _text.bindByTextQueries)(instance),
20
+ return {
21
+ ...(0, _text.bindByTextQueries)(instance),
33
22
  ...(0, _testId.bindByTestIdQueries)(instance),
34
23
  ...(0, _displayValue.bindByDisplayValueQueries)(instance),
35
24
  ...(0, _placeholderText.bindByPlaceholderTextQueries)(instance),
@@ -42,7 +31,6 @@ function within(instance) {
42
31
  ...(0, _unsafeProps.bindUnsafeByPropsQueries)(instance)
43
32
  };
44
33
  }
45
-
46
34
  const getQueriesForElement = within;
47
35
  exports.getQueriesForElement = getQueriesForElement;
48
36
  //# sourceMappingURL=within.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"within.js","names":["within","instance","bindByTextQueries","bindByTestIdQueries","bindByDisplayValueQueries","bindByPlaceholderTextQueries","bindByLabelTextQueries","bindByHintTextQueries","bindByRoleQueries","bindByA11yStateQueries","bindByA11yValueQueries","bindUnsafeByTypeQueries","bindUnsafeByPropsQueries","getQueriesForElement"],"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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,SAASA,MAAT,CAAgBC,QAAhB,EAA6C;EAClD,OAAO,EACL,GAAG,IAAAC,uBAAA,EAAkBD,QAAlB,CADE;IAEL,GAAG,IAAAE,2BAAA,EAAoBF,QAApB,CAFE;IAGL,GAAG,IAAAG,uCAAA,EAA0BH,QAA1B,CAHE;IAIL,GAAG,IAAAI,6CAAA,EAA6BJ,QAA7B,CAJE;IAKL,GAAG,IAAAK,iCAAA,EAAuBL,QAAvB,CALE;IAML,GAAG,IAAAM,+BAAA,EAAsBN,QAAtB,CANE;IAOL,GAAG,IAAAO,uBAAA,EAAkBP,QAAlB,CAPE;IAQL,GAAG,IAAAQ,iCAAA,EAAuBR,QAAvB,CARE;IASL,GAAG,IAAAS,iCAAA,EAAuBT,QAAvB,CATE;IAUL,GAAG,IAAAU,mCAAA,EAAwBV,QAAxB,CAVE;IAWL,GAAG,IAAAW,qCAAA,EAAyBX,QAAzB;EAXE,CAAP;AAaD;;AAEM,MAAMY,oBAAoB,GAAGb,MAA7B"}
1
+ {"version":3,"file":"within.js","names":["within","instance","bindByTextQueries","bindByTestIdQueries","bindByDisplayValueQueries","bindByPlaceholderTextQueries","bindByLabelTextQueries","bindByHintTextQueries","bindByRoleQueries","bindByA11yStateQueries","bindByA11yValueQueries","bindUnsafeByTypeQueries","bindUnsafeByPropsQueries","getQueriesForElement"],"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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,SAASA,MAAM,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;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "11.2.0",
3
+ "version": "11.4.0",
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",
@@ -26,36 +26,36 @@
26
26
  "dont-cleanup-after-each.js"
27
27
  ],
28
28
  "devDependencies": {
29
- "@babel/cli": "^7.8.4",
30
- "@babel/core": "^7.9.0",
31
- "@babel/plugin-proposal-class-properties": "^7.8.3",
32
- "@babel/plugin-transform-flow-strip-types": "^7.18.0",
33
- "@babel/preset-env": "^7.9.6",
34
- "@babel/preset-flow": "^7.9.0",
35
- "@babel/preset-react": "^7.9.4",
36
- "@babel/preset-typescript": "^7.16.0",
29
+ "@babel/cli": "^7.18.10",
30
+ "@babel/core": "^7.19.1",
31
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
32
+ "@babel/plugin-transform-flow-strip-types": "^7.19.0",
33
+ "@babel/preset-env": "^7.19.1",
34
+ "@babel/preset-flow": "^7.18.6",
35
+ "@babel/preset-react": "^7.18.6",
36
+ "@babel/preset-typescript": "^7.18.6",
37
37
  "@callstack/eslint-config": "^13.0.1",
38
- "@testing-library/jest-native": "~4.0.2",
39
- "@types/jest": "^29.0.2",
38
+ "@testing-library/jest-native": "^5.0.0",
39
+ "@types/jest": "^29.2.0",
40
40
  "@types/react": "~18.0.18",
41
41
  "@types/react-native": "~0.70.0",
42
42
  "@types/react-test-renderer": "~18.0.0",
43
- "babel-jest": "^29.0.3",
43
+ "babel-jest": "^29.2.2",
44
44
  "conventional-changelog-cli": "^2.2.2",
45
45
  "dedent": "^0.7.0",
46
46
  "del-cli": "^5.0.0",
47
47
  "eslint": "^8.21.0",
48
48
  "flow-bin": "~0.170.0",
49
49
  "flow-copy-source": "^2.0.9",
50
- "jest": "^29.0.3",
50
+ "jest": "^29.2.2",
51
51
  "react": "18.1.0",
52
- "react-native": "0.70.0",
52
+ "react-native": "0.70.4",
53
53
  "react-test-renderer": "18.1.0",
54
54
  "strip-ansi": "^6.0.0",
55
55
  "typescript": "^4.0.2"
56
56
  },
57
57
  "dependencies": {
58
- "pretty-format": "^29.0.3"
58
+ "pretty-format": "^29.0.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "jest": ">=28.0.0",
@@ -71,7 +71,7 @@
71
71
  "scripts": {
72
72
  "clean": "del build",
73
73
  "test": "jest",
74
- "test:ci": "jest --maxWorkers=2",
74
+ "test:ci": "jest --maxWorkers=2 --collectCoverage=true --coverage-provider=v8",
75
75
  "test:ci:react:17": "scripts/test_react_17",
76
76
  "typecheck": "tsc",
77
77
  "flow": "flow",
@@ -97,6 +97,7 @@
97
97
  "testTimeout": 60000,
98
98
  "transformIgnorePatterns": [
99
99
  "/node_modules/(?!(@react-native|react-native)/).*/"
100
- ]
100
+ ],
101
+ "clearMocks": true
101
102
  }
102
103
  }