http-backend-proxy
http-backend-proxy copied to clipboard
precedence of passThrought() calls and mock calls
Hi the core anguraljs httBackend has this shortcoming that if you want some request to pass you have to specify them after your mock request, this means that you cannot have it nicely layout in the jasmine test where you would put all your passThrough() stuff in beforeAll() and the requests you actually want to mock in the test in self.
Are you able to add such a functionality ? I was hoping that the onLoad can do this but it does not.
I am not sure I understand what you are trying to do. The assertion that you have to put your mocks before the passthrough makes me thing you are not setting things up quite right. If you can give me a concrete example I may be able to help you.
well simply put if I do proxy.load.when('method type','/.*/',).passThrough() // for all method types e.g post,get etc. and then at the next line od actually try to mock particular url, this line will be skipped but if I do passThrough() after the line when im mocking url everything works fine
Yes that makes sense. Again this has nothing to do with the proxy, this is the behavior of the httpBackend itself. When intercepting a request, it checks for registered handlers in the order they are registered. So if you register a universal passThrough first, it will be found first and used and processing stops there. If you register it last, then if a more specific one is found first, it gets used and the passthrough becomes a catch-all at the end. Think of it vaugly as a switch statement with the 'default' at the end.