Questions tagged [httpbackend]

`$httpBackend` is a fake HTTP backend implementation suitable for unit testing applications that use the `$http` service in Angular.js.

$httpBackend is a fake HTTP backend implementation suitable for unit testing applications that use the $http service in Angular.js.

222 questions
3
votes
1 answer

Is where way to mock image which comes from API with $httpBackend of angularjs?

i'm doing protractor tests and using angular-mocks to "fake" requests. In my app where is one place where image should be displayed: Is it possible to intrcept the request for getting image data and…
happyZZR1400
  • 2,387
  • 3
  • 25
  • 43
3
votes
1 answer

Jasmine test using spyon with $httpBackend not working

I am trying to write a jasmine test on some javascript using spyon over a method that uses $http. I have mocked this out using $httpBackend and unfortunately the spy doesn't seem to be picking up the fact the method has indeed been called post $http…
sarin
  • 5,227
  • 3
  • 34
  • 63
3
votes
0 answers

httpBackend expect request only once

After a bit of trial and error I finally managed to get Jasmine to inject a mock Angular service and also provide $httpBackend in the same suite: describe('services.system', function () { var httpBackend, nodeService; …
seanhodges
  • 17,426
  • 15
  • 71
  • 93
3
votes
1 answer

AngularJS: testing actual $http requests (not mocks) to get a success() or error() case...?

I've been tasked with setting up some "Integrated Tests" (not "Unit Tests" or "UI tests" [aka. E2E/Protractor]). This integrated test is doing nothing more than testing the controller's $http POST request to the external API, and checking for an…
3
votes
0 answers

How to make a back-end service for uploading video from iPhone

I want to upload an video from iPhone to Back-end server. For this how to make a receiving part on Back-end server? I want to make the back-end server in PHP.
Janos
  • 64
  • 9
3
votes
2 answers

Delaying a response with $httpBackend

In my view I have loading animation that is displayed until I receive a response from the API. //Displayed before we've received API response

Loading ...

//Displayed once we received response for the API
NicolasMoise
  • 7,261
  • 10
  • 44
  • 65
3
votes
1 answer

Using Protractor with $httpBackend correctly

I've read about how Protractor works, I've written several E2E tests in it and still I feel uncomfortable about using it with $httpBackend service and I think it's possible I'm missing an important part of the picture. In order to have the HTTP…
NOtherDev
  • 9,542
  • 2
  • 36
  • 47
3
votes
1 answer

Jasmine test with httpBackend doesn't return expected result

I have a very simple unit test for my $resource-wrapping service. I have httpBackend mocked and setup to return an array of seven items. When I run the test, it reports that 4 items have been returned, not 7: function (a1, a2, a3, a4) { ...…
3
votes
2 answers

AngularJS unit test for directive that queries server returns "Unsatisfied requests"

I have a bookmarking app that takes in a url and automatically extracts a summary. When the client requests the server to add a new bookmark, the server sends back some initial information and initiates a process to extract the summary. In the…
3
votes
2 answers

$httpBackend.whenGET with more than one parameter

I have this URL to match: $httpBackend.whenGET('/api/alerts/1121212156/0/4/0').repond(someObject) The problem is that 1121212156 is a tick so it can be different every time. Does someone know how to create a regex to do that?
2
votes
1 answer

React Native app cannot reach backend API on Android, without using Charles + SSL tunnelling

My RN app works perfectly on iOS. But on Android, it cannot reach the backend (hosted in cloud using https) or any other URL like https://randomuser.me/api But when I make the device use Charles as HTTP proxy, install the Charles root certificate…
Esben von Buchwald
  • 2,772
  • 1
  • 29
  • 37
2
votes
1 answer

Protractor version 5.0 Http-backend-proxy failing

I upgraded from protractor version 4.0.14 to version 5.0.0 and now my tests are failing. I use http-backend-proxy for mocking the backend. The tests run fine with version 4.0.14, but fails with an InvalidElementState error when I upgrade to version…
2
votes
2 answers

angular jasmine multiple nested httpbackend calls

I am trying to test a angularjs service with jasmine that calls a resource service and in the then function calls another nested resource function. I am using httpbackend to flush mock responses. The issue is that, while testing, it is not flushing…
Luke Flournoy
  • 3,393
  • 2
  • 16
  • 22
2
votes
0 answers

$httpBackend.expectGET() without URL still captures request

Doing AngularJS unit tests using the $httpBackend service. For some reason $httpBackend.expectGET('') or $httpBackend.expectGET() seem to be working like a catch-all for the request coming from the tested code i.e. Karma says the test passes with…
2
votes
1 answer

Angular $httpBackend error "No more request expected"

Below is my controller, function adminController($scope, $http, $location) { $scope.enabledRights = []; $http.get('user/rights').success(function(data) { $scope.enabledRights = data; }).error(function() { $scope.enabledRights =…