File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -276,9 +276,20 @@ getByLabelText('username').value = 'chucknorris'
276
276
// ...
277
277
` ` `
278
278
279
- This can be useful when (for example ) you integration test your apollo -connected
280
- react components that go a couple level deep , with queries fired up in
281
- consequent components.
279
+ This can be useful if you have a unit test that mocks API calls and you need
280
+ to wait for your mock promises to all resolve . This can also be useful when
281
+ (for example ) you integration test your apollo -connected react components that
282
+ go a couple level deep , with queries fired up in consequent components.
283
+
284
+ The default ` callback ` is a no -op function (used like ` await wait() ` ). This can
285
+ be helpful if you only need to wait for one tick of the event loop.
286
+
287
+ The default ` timeout ` is ` 4500ms ` which will keep you under
288
+ [Jest ' s default timeout of `5000ms`](https://facebook.github.io/jest/docs/en/jest-object.html#jestsettimeouttimeout).
289
+
290
+ The default ` interval ` is ` 50ms ` . However it will run your callback immediately
291
+ on the next tick of the event loop (in a ` setTimeout ` ) before starting the
292
+ intervals .
282
293
283
294
## Custom Jest Matchers
284
295
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ function flushPromises() {
25
25
return new Promise ( resolve => setImmediate ( resolve ) )
26
26
}
27
27
28
- function wait ( callback = ( ) => { } , { timeout, interval} = { } ) {
28
+ function wait ( callback = ( ) => { } , { timeout = 4500 , interval = 50 } = { } ) {
29
29
return waitForExpect ( callback , timeout , interval )
30
30
}
31
31
You can’t perform that action at this time.
0 commit comments