Closed franzcatch closed 4 years ago
I was thinking this would match ALL traffic coming from the browser would get matched up with the mock created. However, I could be mistaken, but looking at the underlying code closer - it seems that xhr-mock is only meant to intercept calls made from a new XMLHttpRequest();
.
It seems that all of the needed pieces to facilitate intercepting all browser traffic with a mock are here in this logic. Perhaps consider tweaking the code a bit to intercept all network traffic and match it up with mocks that are in place so you don't have to deliberately trigger a send
from a new XMLHttpRequest();
?
Sample code:
Note: I am using this with Protractor on a web app built on Angular 1.5.11.
Note the
console.log("code never gets here")
never gets executed. I also putconsole.log
insidecreateMockFunction
and it never gets called. I did put one intoMockXMLHttpRequest.addHandler
and it does get called. So for some reason, the handler is not triggering the mock function.Am I doing something wrong here? Have tried several regex to no avail.