Open tom-drake opened 5 years ago
Yep sounds reasonable. From memory, because we've replaced the global XMLHttpRequest, we don't have access to the real XMLHttpRequest within a handler so using fetch
was a hack to send real requests instead of mock ones.
In v3 the handler will receive a context object that we can put the real XMLHttpRequest on.
If this is going into a future version then great. I worked around this by creating my own proxy that makes use of XHRMock.RealXMLHttpRequest which seems to give me access to the real one before being overridden.
I noticed that if a request is proxied it is done as a fetch rather than an XHR. Would it make sense just to use the RealXMLHttpRequest rather than 'http' and 'https'?