I\'m trying to match an url with a regex. But the follwing regex doesn\'t match.
$httpBackend.whenGET(\'/^rest\\/find-reservations\\?.*/)\').respond(function
If you want to match this url:
"rest/find-reservations?end=1421424299193&reservationClass=Reservation&start=1358352299193"
use this code:
$httpBackend.whenGET(/^rest\/find-reservations\?.*/).respond(function () {
return [200, ['success'], {}];
});
Error: Unexpected request:
It can be for some reasons:
$httpBackend.expectGET(url)
.expectGET
should be the same as the order of the requests
.$httpBackend.verifyNoOutstandingExpectation()
before $httpBackend.flush()
.It is not related to $httpBackend.whenGET
at all.
From the $httpBackend docs:
Request expectations provide a way to make assertions about requests made by the application and to define responses for those requests. The test will fail if the expected requests are not made or they are made in the wrong order