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
493
493
494
-
```js
495
-
// api.js
496
-
497
-
import'cross-fetch'
498
-
499
-
exportfunctionAPIRequest(who) {
500
-
if (who ==='facebook') {
501
-
returnfetch('https://facebook.com')
502
-
} elseif (who ==='twitter') {
503
-
returnfetch('https://twitter.com')
504
-
} else {
505
-
returnfetch('https://google.com')
506
-
}
507
-
}
508
-
```
509
-
510
494
```js
511
495
// api.test.js
512
-
import { APIRequest } from'./api'
496
+
import { request } from'./api'
513
497
514
498
describe('testing timeouts', () => {
515
499
it('resolves with function and timeout', async () => {
0 commit comments