@@ -152,50 +152,90 @@ variable to `true` before importing `@testing-library/react-hooks` will also dis
152
152
### ` waitForNextUpdate `
153
153
154
154
` ` ` js
155
- function waitForNextUpdate (options ?: WaitOptions ): Promise<void>
155
+ function waitForNextUpdate (options ?: {
156
+ timeout?: number
157
+ }): Promise<void>
156
158
```
157
159
158
160
Returns a `Promise` that resolves the next time the hook renders, commonly when state is updated as
159
161
the result of an asynchronous update.
160
162
161
- See the [`wait` Options](/reference/api#wait-options) section for more details on the available
162
- `options`.
163
+ #### `timeout`
163
164
164
- ### `wait`
165
+ The maximum amount of time in milliseconds (ms) to wait. By default, no timeout is applied.
166
+
167
+ ### `waitFor`
165
168
166
169
```js
167
- function wait(callback: function(): boolean|void, options?: WaitOptions): Promise<void>
170
+ function waitFor(callback: function(): boolean|void, options?: {
171
+ interval?: number,
172
+ timeout?: number,
173
+ suppressErrors?: boolean
174
+ }): Promise<void>
168
175
```
169
176
170
177
Returns a `Promise` that resolves if the provided callback executes without exception and returns a
171
178
truthy or `undefined` value. It is safe to use the [`result` of `renderHook`](/reference/api#result)
172
179
in the callback to perform assertion or to test values.
173
180
174
- The callback is tested after each render of the hook. By default, errors raised from the callback
175
- will be suppressed (`suppressErrors = true`).
181
+ #### `interval`
176
182
177
- See the [`wait` Options](/reference/api#wait-options) section for more details on the available
178
- `options`.
183
+ The amount of time in milliseconds (ms) to wait between checks of the callback if no renders occur.
184
+ By default, an interval of 50ms is used.
185
+
186
+ #### `timeout`
187
+
188
+ The maximum amount of time in milliseconds (ms) to wait. By default, no timeout is applied.
189
+
190
+ #### `suppressErrors`
191
+
192
+ If this option is set to `true`, any errors that occur while waiting are treated as a failed check.
193
+ If this option is set to `false`, any errors that occur while waiting cause the promise to be
194
+ rejected. By default, errors are suppressed for this utility.
179
195
180
196
### `waitForValueToChange`
181
197
182
198
```js
183
- function waitForValueToChange(selector: function(): any, options?: WaitOptions): Promise<void>
199
+ function waitForValueToChange(selector: function(): any, options?: {
200
+ interval?: number,
201
+ timeout?: number,
202
+ suppressErrors?: boolean
203
+ }): Promise < void >
184
204
```
185
205
186
206
Returns a ` Promise ` that resolves if the value returned from the provided selector changes. It
187
207
expected that the [ ` result ` of ` renderHook ` ] ( /reference/api#result ) to select the value for
188
208
comparison.
189
209
190
- The value is selected for comparison after each render of the hook. By default, errors raised from
191
- selecting the value will not be suppressed (`suppressErrors = false`).
210
+ #### ` interval `
211
+
212
+ The amount of time in milliseconds (ms) to wait between checks of the callback if no renders occur.
213
+ By default, an interval of 50ms is used.
214
+
215
+ #### ` timeout `
216
+
217
+ The maximum amount of time in milliseconds (ms) to wait. By default, no timeout is applied.
218
+
219
+ #### ` suppressErrors `
192
220
193
- See the [`wait` Options](/reference/api#wait-options) section for more details on the available
194
- `options`.
221
+ If this option is set to ` true ` , any errors that occur while waiting are treated as a failed check.
222
+ If this option is set to ` false ` , any errors that occur while waiting cause the promise to be
223
+ rejected. By default, errors are not suppressed for this utility.
195
224
196
- ### `wait` Options
225
+ ### ` wait `
197
226
198
- The async utilities accept the following options:
227
+ _ (DEPRECATED, use [ ` waitFor ` ] ( /reference/api#waitFor ) instead)_
228
+
229
+ ``` js
230
+ function waitFor (callback : function (): boolean|void, options?: {
231
+ timeout?: number,
232
+ suppressErrors?: boolean
233
+ }): Promise<void>
234
+ ```
235
+
236
+ Returns a `Promise` that resolves if the provided callback executes without exception and returns a
237
+ truthy or `undefined` value. It is safe to use the [`result` of `renderHook`](/reference/api#result)
238
+ in the callback to perform assertion or to test values.
199
239
200
240
#### `timeout`
201
241
@@ -205,5 +245,4 @@ The maximum amount of time in milliseconds (ms) to wait. By default, no timeout
205
245
206
246
If this option is set to `true`, any errors that occur while waiting are treated as a failed check.
207
247
If this option is set to `false`, any errors that occur while waiting cause the promise to be
208
- rejected. Please refer to the [utility descriptions](/reference/api#async-utilities) for the default
209
- values of this option (if applicable).
248
+ rejected. By default, errors are suppressed for this utility.
0 commit comments