You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default you will want to have your fetch mock return immediately. However if you have some custom logic that needs to tests for slower servers, you can do this by passing it a function and returning a promise when your function resolves
492
+
493
+
```js
494
+
// api.js
495
+
496
+
import'cross-fetch'
497
+
498
+
exportfunctionAPIRequest(who) {
499
+
if (who ==='facebook') {
500
+
returnfetch('https://facebook.com')
501
+
} elseif (who ==='twitter') {
502
+
returnfetch('https://twitter.com')
503
+
} else {
504
+
returnfetch('https://google.com')
505
+
}
506
+
}
507
+
```
508
+
509
+
```js
510
+
// api.test.js
511
+
import { APIRequest } from'./api'
512
+
513
+
describe('testing timeouts', () => {
514
+
it('resolves with function and timeout', async () => {
0 commit comments