http-backend-proxy
http-backend-proxy copied to clipboard
Mocked POST ignored
Hi my protractor + jasmine test looks as follows
beforall =>
mock a post request on page load pass through all requests on page load
it =>
test if the mocked post above is working ( true)
do another post mock (not using onLoad)
test if this mocked post is working ( false) // this fails looks like passing trough all request in the beforeall overrides the post mock in the "it" method ?
//even if i add passThrough() for all requests (not onLoad) it does not make any difference.
If I am understanding your scenario correctly, you are correct that the pass through that you setup on page load will effect everything thereafter. This is just the way the httpBackend works. Little do to with the proxy. You may want to look at this section of the docs for some possible help.
yeah i don't really want refresh the page in order to reset the mock but according to the angular documentation you can actually override the request so maybe the 'reset' functionality can be achieved this way. "Both methods return the requestHandler object for possible overrides."
https://docs.angularjs.org/api/ngMockE2E/service/$httpBackend
Hmm. So full transparency here. I have been out of regular angular dev for 2+ years now so its possible they have improved how things work. My recollection is that that doesn't quite work as you might expect.
My recommendation would be to set aside my proxy for a bit and come up with a working example the does what you want using the httpBackend directly. If that sort of overriding really works as you expect, then we can strategize how to correctly proxy it.