Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocked fetch throws a DOMException when executing with an already aborted signal #237

Open
valeriobelli opened this issue Jul 15, 2022 · 0 comments

Comments

@valeriobelli
Copy link

valeriobelli commented Jul 15, 2022

Hi all!

While executing tests in one of my private repositories, I've seen a weird behaviour which differs from the expected behaviour of native fetch.

When executing the fetch function with an already aborted signal, normalizeRequest (https://github.com/jefflau/jest-fetch-mock/blob/master/src/index.js#L123-L142) throws a DOMException. However, since this function is synchronous, the Error bubbles up without having the chance to intercept its failure with a rejected Promise as it happens with the native implementation. As you can imagine, the result is failing tests.

I'm wondering: is it intended behaviour?

Here, you can find a repo with the reproduction step of what I intend. I've put both the expected and unexpected behaviours.

I am available to help you. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant