$httpBackend
mocks HTTP requests, enabling testing without actual server calls. It’s used to simulate $http
calls, allowing predictable tests and error handling. With expectGET()
and .flush()
, $httpBackend
enables robust, isolated tests for HTTP-dependent components.
$httpBackend.expectGET('/api/data').respond(200, { data: 'mockData' });
$httpBackend.flush(); // Triggers the mock response