-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Does not work when mocking window.fetch
#151
Comments
You can do a PR only if you want to. Nobody says you have to. That would be cool. Rejected PRs don't make you look bad. The opposite, they make you look better because you showed some effort. I mean it would be cool to see this in production. |
window.fetch
We swap out the |
@sholladay What about putting these: Lines 24 to 30 in 2ea165a
into an object and exposing it via |
I think I'd rather put the I'm curious to know why mocking fetch before Ky loads is not enough. It's definitely a safer way to do things. |
I agree with @sholladay. The convention is to mock before importing something. |
That's one way to go. If we were using but just pass an object with these values. Although I don't see anything wrong with the current solution. |
Thats not true. The tests of
I highly disagree! This makes it almost impossible to write independent tests with tools like So people want to do things like this:
some context:
The later is especially problematic. I don't think its a good idea that all apps should need to hook into the test loader (which loads the app and test tests, so I think its the only place to import something before the app is loaded, which then always will import |
This is very bad for testing.
when using
ky
tools like pretender can not work, becauseky
stores a reference tofetch
immediatly after its loaded withconst fetch = getGlobal('fetch');
.This means when a tool like
pretender
overwriteswindow.fetch
for testingky
does not use the newwindow.fetch
but the stored reference to the real fetch and so does a real request.Is there a good reason to not call
getGlobal('fetch')
wheneverfetch
is required? (currently only here and here)I'm willing to do a PR, but only if it will be merged.
The text was updated successfully, but these errors were encountered: