-
Notifications
You must be signed in to change notification settings - Fork 178
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
Not working in IE11 #415
Comments
It'll be a while til I can look at this as will need to set up an ie11 environment and configure CI to run in ie11 too, which is not a trivial task. Would be great if you're able to work on a fix and submit a PR |
I have been looking into this. On a project we're running our unit test suite in IE11 (and other browsers) and have not been able to upgrade to fetch-mock@7 for this and a variety of other reasons. Today I was able to get it to work with these measures:
I would like to submit the patch as a pull request, if there is a chance that it would get merged? |
Thanks Lars. I have a few questions
Is this duck-typing to detect whatwg-fetch?
Why was bodyUsed ever How would you feel if I exposed the response constructor class, then you could do
Could even publish your entire ie11 solution as an npm module in its own right |
Hey Rhys, thank you for your quick reply!
Yes, that's correct.
It was not true. The problem is that the
Yes, I agree. Maybe the root cause here is that the Response object is not constructed correctly by fetch-mock (https://github.com/wheresrhys/fetch-mock/blob/master/src/lib/response-builder.js#L19)? Usually when using whatwg-fetch, If we could initialize the Response object "more correctly" - that would be a better solution. Do you have any suggestions for how to do that? |
FYI I am running into the same original issue. Downgrading to fetch-mock 6.5.2 seems to fix the issue for me. |
I'm unsure what solution was decided on here? Minor update: figured out that whatwg-fetch initially sets Update: I created a PR in fetch-mock to try and address this; I'm not sure they'll accept it because this Proxy use case is edgy. Will keep our fingers crossed. For the record my use case is phantomjs-prebuilt@2.1.7, fetch-mock@8.0.0-alpha.14, proxy-pollyfill@0.3.0 on CentOS 6. |
Fixes wheresrhys/fetch-mock#415 Details: fetch-mock wraps the Response object in an ES6 Proxy to provide useful test harness features such as flush. However, on ES5 browsers without fetch or Proxy support pollyfills must be used; the proxy-pollyfill is unable to proxy an attribute unless it exists on the object before the Proxy is created. This change ensures Response.bodyUsed exists on the instance, while maintaining the semantic of setting Request.bodyUsed in the constructor before _initBody is called.
Thanks for submitting the PR to whatwg-fetch. Hope it gets accepted. If it's not accepted I'll consider a PR to fix here by always setting to false on setup. There's a new major version of fetch-mock coming out soon, which gives me an opportunity to fix undocumented edge cases that people may, inadvertently, be relying on being buggy |
Great news. started to encounter the same issues on IE-11. As a side note we are also experiencing
We use it to test https://github.com/wp-headless/fetch if your interested in our test harness, happy to help. |
As of fetch-mock v9.3.1, the issue still persist. I first came across the problem by updating from v7.4.0 to v9.3.1. I traced back versions and it appears v8.0.0 breaks it. The error I get on IE11 points to the line 5 of src/lib/request-utils.js the arrow function It appears the arrow function is not being transpiled properly to IE 11 supported syntax. |
Yeah, they never accepted the fetch PR. Would be great if you guys could go ask it gets accepted. Meanwhile I've been doing npm installs for fetch directly off the fork.
|
My findings with getting tl;dr
referenced here GoogleChrome/proxy-polyfill#49 |
It seems like github have abandoned the fetch polyfill. I've raised an issue which may get looked at JakeChampion/fetch#777. |
The reasoning is there is now such wide support for fetch and IE 11 is not being supported moving forward. |
* Compatibility for fetch-mock using proxy-pollyfill Fixes wheresrhys/fetch-mock#415 Details: fetch-mock wraps the Response object in an ES6 Proxy to provide useful test harness features such as flush. However, on ES5 browsers without fetch or Proxy support pollyfills must be used; the proxy-pollyfill is unable to proxy an attribute unless it exists on the object before the Proxy is created. This change ensures Response.bodyUsed exists on the instance, while maintaining the semantic of setting Request.bodyUsed in the constructor before _initBody is called. * Update fetch.js Co-authored-by: Jake Champion <me@jakechampion.name>
fetch accepted the PR. Thank you. |
still waiting github/fetch to release the fix to NPM |
The latest version of github/fetch is now in NPM. |
This section of the docs might help @carlosrberto http://www.wheresrhys.co.uk/fetch-mock/#usageimporting Gonna close this issue... finally |
The |
* Compatibility for fetch-mock using proxy-pollyfill Fixes wheresrhys/fetch-mock#415 Details: fetch-mock wraps the Response object in an ES6 Proxy to provide useful test harness features such as flush. However, on ES5 browsers without fetch or Proxy support pollyfills must be used; the proxy-pollyfill is unable to proxy an attribute unless it exists on the object before the Proxy is created. This change ensures Response.bodyUsed exists on the instance, while maintaining the semantic of setting Request.bodyUsed in the constructor before _initBody is called. * Update fetch.js Co-authored-by: Jake Champion <me@jakechampion.name>
When I'm importing fetch-mock (7.3.0) in IE11 I get an error
Expected identifier
which traces to the linefunction findStatus(val, { useSTD3ASCIIRules })
which seems to come from 'tr46' dependency.Since this module is imported as a string in the 'es5/client-bundle.js', webpack can't transpile it correctly (and argument destructuring actually is also not an es5 feature at all).
The text was updated successfully, but these errors were encountered: