http-backend-proxy icon indicating copy to clipboard operation
http-backend-proxy copied to clipboard

Mocked POST ignored

Open KWodarczyk opened this issue 8 years ago • 3 comments

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.

KWodarczyk avatar Dec 08 '16 07:12 KWodarczyk

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.

kbaltrinic avatar Dec 16 '16 23:12 kbaltrinic

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

KWodarczyk avatar Dec 16 '16 23:12 KWodarczyk

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.

kbaltrinic avatar Jan 06 '17 11:01 kbaltrinic