File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 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'
276276// ...
277277` ` `
278278
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 .
282293
283294## Custom Jest Matchers
284295
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ function flushPromises() {
2525 return new Promise ( resolve => setImmediate ( resolve ) )
2626}
2727
28- function wait ( callback = ( ) => { } , { timeout, interval} = { } ) {
28+ function wait ( callback = ( ) => { } , { timeout = 4500 , interval = 50 } = { } ) {
2929 return waitForExpect ( callback , timeout , interval )
3030}
3131
You can’t perform that action at this time.
0 commit comments