javascript - AngularJS : $httpBackend mock only some requests -
i use ngmock module mock several requests so:
$httpbackend.whenget("/accounts").respond([obj]);
however, seems loading module expects mock requests. if other request other mocked, "unexpected request" error.
how can configure intercepts requests mock explicitly, , passes else through?
you can use regex , passthrough() function built $httpbackend.
beforeeach(inject(function($httpbackend){ $httpbackend.whenget("/accounts").respond([obj]); //pass else through $httpbackend.whenget(/^\w+.*/).passthrough(); }));
Comments
Post a Comment