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
0
votes
1 answer

Callback registered with respond is not executed when path is matched

I am trying to test an AngularJS directive which uses an HTML template through a reference. Because of that, it is issuing an http request. What I am trying to do is capturing all requests for the templates using…
Javier
  • 79
  • 2
  • 4
0
votes
2 answers

AngularJS + Jasmine: Unexpected http calls

I started writing tests for an existing application and encountered two problems. Here is service method I'm trying to cover: function getClinic(id) { return $http .get("api/clinic/" + id) .then(function (resp) { …
Majesty
  • 2,097
  • 5
  • 24
  • 55
0
votes
0 answers

Protractor addMockModule for angular applications without ngApp

The angular application on which I am running my e2e tests does not have ngApp directive and bootstraps manually. Is it not possible to insert mock modules via Protractor in this case? //load angular mocks as a string here var angularMocks =…
Manya
  • 315
  • 4
  • 17
0
votes
1 answer

Unable to Inject $httpBackend

I am using Angular 1.5 to write mocked services for my project by following this little example: https://embed.plnkr.co/qsmx8RUmQlXKkeXny7Rx/ This is a simple code that I have written so far: function() { 'use strict'; angular.module('agMock',…
Amna Tariq
  • 135
  • 1
  • 9
0
votes
2 answers

Ensuring $httpBackend flush for series of requests

I have a need to test an in-house angular service implemented under Angular 1.5.9 with jasmine/karma. I need to write a test which checks that the response of a particular service function is as expected. To do this I am constructing a mock object,…
Matt W
  • 11,753
  • 25
  • 118
  • 215
0
votes
2 answers

how to make variable and use in UITableView in swift 3

I am successfully appending "title" , "url" and Video in these Global Variables but when I am trying to use in numberOfRowsInSection as ( return titleName.count ) so I am getting nil or in (cellForRowAt indexPath: ) as cell.videoTitle.text =…
King
  • 259
  • 1
  • 4
  • 12
0
votes
1 answer

checking backend health for more than 2 web servers in varnish 4

have a varnish server with 3 backends. all backends are apache. everything is ok and the varnish server caches everything I need, and the connections are OK. I wnat to monitor the health of web servers. and in case of a failure, varnish does not…
0
votes
1 answer

ngMockE2E - $http keeps returning

I've been trying to write app in Angular 1.6 in ES6 and I wanted to use that fake HTTP Backend from ngMockE2E: https://docs.angularjs.org/api/ngMockE2E/service/$httpBackend So I implemented those API calls like this in home.run.js: mocks.$inject =…
0
votes
0 answers

Mock $http with configuration parameters

I'm applying some tests in an existing AngularJS application in order to ensure it's correct behaviour for future changes in the code. I am pretty new with Jasmine & Karma testing, so I've decided to start with a small and basic service which…
marc
  • 527
  • 6
  • 23
0
votes
1 answer

Is this OK to redirect to `PUT`, `DELETE` methods?

In my application I have route /users/37/verify_email. Because action for this route updates activation info in database I ask client to complete this request with PUT method. In application on backend there are many steps to verify. After success…
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
0
votes
1 answer

Unsure on how to successfully test this function using $httBackend

This is the function in the controller: var vm = this; vm.getData = getData; function getData(val) { return $http.get('/get-data', { params: { query: val } }).then(function(response) { return response.data; }); } and this…
J_P
  • 599
  • 1
  • 9
  • 20
0
votes
0 answers

$httpBackend not stubbing the response for second function

I am new to unit testing in angular and I am using Mocha/Chai for unit testing in this angular app. I was able to stub the getApplications() function's response, but I am unable for the load() function's response. Both are using $http to make a GET…
0
votes
1 answer

$httpBackend mocking not return a response

I've mocked an httpBackend to test the following code. self.Api.post('/endpoint/action/', actionData) .then(function(resp){ result = _.get(resp, 'data.MessageList'); if(resp.status = 200 && result) { for (var i = 0; i <…
acostela
  • 2,597
  • 3
  • 33
  • 50
0
votes
0 answers

Unit test Karma - Error: Unexpected request: GET "..."

I'm trying to unit test my project built on Angular with Karma-jasmine. When I run the test I get this error: Error: Unexpected request: GET assets/l10n/en.js This is my spec file: describe('test Overview Factory', function() { var…
0
votes
1 answer

Jasmine test error on Jenkins Build Server with angular-mocks?

I'm unit testing a angular directive with Angular and Jasmine. Mocking the http backend works fine and all tests working fine locally. But on the build server i get: Error: Unexpected request: GET app/auth/views/login.html No more request…
Juri
  • 1,531
  • 2
  • 20
  • 43