Add supprot for AbortSignal
See original GitHub issueFetch request can be cancelled through AbortController
API & cross-fetch
library used here is wrapper around node-fetch
library which does support it
It would be really helpful if AbortController
was exposed by this library to allow testing cases where requests may be cancelled.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
AbortSignal - Web APIs - MDN Web Docs - Mozilla
The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a fetch request) and abort ......
Read more >Add support for AbortSignal · Issue #53 · sindresorhus/p-retry
Sometimes you just want to cancel a retry operation: const abortController = new AbortController(); const {signal} = abortController; ...
Read more >Using AbortSignal in Node.js - NearForm
Consult the Node.js documentation for more details on exactly which APIs support AbortSignal . More are being added all the time and support...
Read more >Add support for AbortSignal to cancel requests by jnields · Pull ...
Add support for AbortSignal to cancel requests #539. Merged. bitinn merged 1 commit into node-fetch:master from jnields:add-signal-support on Nov 12, 2018.
Read more >AbortController & AbortSignal | Can I use... Support ... - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Those are coming from cross-fetch, not
jest-fetch-mock
. More importantly, those are part of the specification that need to be supplied byfetch
. AnAbortController
is more generic and, whilefetch
can make use of anAbortController
(by listening to it’s signal), it’s not required forfetch
to function (unlikeHeaders
,Response
, andRequest
).I still fail to see the use case - if you want to test an aborted fetch, then you should already have an implementation of
AbortController
. Right nowjest-fetch-mock
still doesn’t support testing aborted fetches, but this is just me advocating for my PR 😄@akmjenkins if
fetch
,Headers
,Response
,Request
all come from here I would expectAbortController
to do the samehttps://github.com/jefflau/jest-fetch-mock/blob/454fcc956de67175567ced958c28b0c33bbd0f10/src/index.js#L49-L52