You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
when using ngMockE2E's httpBackend, the request URLs are to be matched to be equal strings. This limits mocking to have parameters in specific order (sorted alphabetically right now). Url path should be matched by string and the parameters should be parsed and compared and tested for :
are all and only those parameters specified are present
The workaround right now is to sort all query params alphabetically.This is ok for small amount of mocking, but when it is needed for a lot of data, like for protractor testing for a client side only app where all backend (or most) need to be mocked, this becomes a big pain.
The text was updated successfully, but these errors were encountered:
Yeh, I can totally feel the pain :-/ We've got an issue for this already:#7348
I think we should expose somehow the service that serialises request params so people can use it from tests. I'm going to push for this in 1.4 (or even 1.3 if we can do this without any breaking changes).
@pkozlowski-opensource did you mean to close this issue? It seems that this is the issue you wanted to move the discussion to. Or did you mean to refer a different issue?
For those of us locked on 1.2, another workaround is regex when() calls, leaving the query params out or writing some potentially-complex regexes, and manually/with-library-of-choice parsing out query params from the url parameter in the corresponding respond() call.
You may run into issues where similar endpoints need to be defined in a specific order (as @mkhanal mentioned) because of this. (or again your regexes need to get more complex/specific...)
As pretty as that is.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
when using ngMockE2E's httpBackend, the request URLs are to be matched to be equal strings. This limits mocking to have parameters in specific order (sorted alphabetically right now). Url path should be matched by string and the parameters should be parsed and compared and tested for :
eg:
$httpBackend.whenGET('urlString?param2=val2¶m1=val1').
respond 200, responseForVal1AndVal2
http.get("urlString", params:{param1: val1, param2: val2})
current : do not match
expected : to match
The workaround right now is to sort all query params alphabetically.This is ok for small amount of mocking, but when it is needed for a lot of data, like for protractor testing for a client side only app where all backend (or most) need to be mocked, this becomes a big pain.
The text was updated successfully, but these errors were encountered: