angularjs - Angular - Jasmine can real XHR be executed? -
i not want have $http mocked. main reason writing integration tests want have ajax requests executed. in tests none gets triggered. suggestion more welcomed.
the angular mocks provide mocked $httpbackend when using jasmine tests, actual $httpbackend still exists. need tell provider use original when inject service. in test:
var original_http_backend = null; angular.module('ng').config(['$httpbackendprovider', function($httpbackendprovider) { original_http_backend = $httpbackendprovider; }]); beforeeach(module(function($provide) { $provide.provider('$httpbackend', original_http_backend) }));
it's worth pointing out approach, in general, bad way test front end code. because adds backend dependency, cannot isolate front end behavior. preferred mock out response , test that.
i did end using feature though, since our mock responses developed on end testing there, , didn't want repeat objects. method allowed me use them.
Comments
Post a Comment