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
2
votes
0 answers

Simulate Network Delay Jasmine Unit Test with $httpBackend

I have an angularjs directive that uses an ng-mouseenter to trigger a call to the backend for data. If the call to the backend goes longer than a certain time, a loading indicator is presented. I'd like to test that the loading indicator gets…
binarygiant
  • 6,362
  • 10
  • 50
  • 73
2
votes
0 answers

Error: Unexpected request: GET layouts/index.html - AngularJS unit test - Karma

I get that error since my app.config file is included in my tests. It makes all my unit tests involving httpbackend fail. They usually look like this: beforeEach(function(){ module('consumerApp'); inject(function($injector) { httpBackend =…
Alex C
  • 1,334
  • 2
  • 18
  • 41
2
votes
0 answers

$httpBackend respond undefined

Trying to get a similar behavior as in Example UnitTest.coffee: describe 'Unit: EditAccessController', -> ... (var $httpBackend, personRequestHandler) personUrl = /\/people\/\d+/ testPerson = { personId: 123 } ... beforeEach inject…
fishko
  • 21
  • 1
2
votes
1 answer

Getting "Unexpected request" error when running Karma unit test in an AngularJS app

I'm trying to write a unit test for a controller which fetches article details using $http service. Controller: .controller('ArticleDetailCtrl',function($scope, Article, $routeParams, API_URL, ARTICLE_URL, $http, $sce){ $scope.url = API_URL +…
2
votes
0 answers

Log all AJAX requests going through $httpBackend

How do I log all requests that go through $httpBackend? I know how to give a mock response with .respond(), how to let the request pass through with .passThrough(), but how can I only intercept the request to log it and then let it pass through?
stackular
  • 1,431
  • 1
  • 19
  • 41
2
votes
1 answer

Can I use some Python in the backend for an Android app?

Most of the backend stuff is in PHP which handle JSON request and response flow of data from Android app to backend. I'd like to start writing Python code to handle the extra features I'm going to add in my app. How can I do that? Do I need to…
Tony K
  • 61
  • 3
  • 10
2
votes
1 answer

Angular 1.2.10 upgrade kills $httpBackend tests

I just upgraded from Angular.js 1.1.3 to 1.2.10 and my $httpBackend tests started failing. Im using QUnit 1.12.0 as a testing framework. I have the following setup in my tests. (function () { var fittingDataServiceMock, injector, ctrl, …
moesef
  • 4,641
  • 16
  • 51
  • 68
1
vote
0 answers

HTTP: Industry standards for back responses to the client

Hi all I'm new to web development so I'm developing a simple online recipe book to allow me to also learn node and angular in the process. How ever I'm struggling with what type of responses I should send back to the client for success and fails, in…
jakegergen
  • 135
  • 1
  • 1
  • 10
1
vote
1 answer

How to handle fetch API request with express js

I want to send request using fetch API and want to handle those request with Express JS. I have created server.js (express JS), index.html (home page) and signin.html (signin page). index.html Home…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/node.js" class="post-tag grid--cell" title="show questions tagged 'node.js'" rel="tag">node.js</a> <a href="../../questions/tagged/express" class="post-tag grid--cell" title="show questions tagged 'express'" rel="tag">express</a> <a href="../../questions/tagged/fetch-api" class="post-tag grid--cell" title="show questions tagged 'fetch-api'" rel="tag">fetch-api</a> <a href="../../questions/tagged/httpbackend" class="post-tag grid--cell" title="show questions tagged 'httpbackend'" rel="tag">httpbackend</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Aug 07 '20 at 15:16">asked Aug 07 '20 at 15:16</time> <a href="../../users/7483046/raktim-banerjee" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/7483046.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="RAKTIM BANERJEE" /> </a> <div class="s-user-card--info"> <a href="../../users/7483046/raktim-banerjee" class="s-user-card--link">RAKTIM BANERJEE</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">304</li> <li class="s-award-bling s-award-bling__silver" title="4 silver badges">4</li> <li class="s-award-bling s-award-bling__bronze" title="12 bronze badges">12</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-59501844"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/59501844/ng-http-loader-not-working-for-api-calls-handled-via-httpbackend" class="question-hyperlink">ng-http-loader not working for API calls handled via httpbackend</a></h3> <div class="excerpt">I was trying to create a service so that all API calls in that service will not be appended with token. I achieved this using HttpBackend. But now the ng-http-loader is not working for these API's. What I Require ng-http-loader to work in API calls…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/angular" class="post-tag grid--cell" title="show questions tagged 'angular'" rel="tag">angular</a> <a href="../../questions/tagged/loader" class="post-tag grid--cell" title="show questions tagged 'loader'" rel="tag">loader</a> <a href="../../questions/tagged/httpbackend" class="post-tag grid--cell" title="show questions tagged 'httpbackend'" rel="tag">httpbackend</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 27 '19 at 14:00">asked Dec 27 '19 at 14:00</time> <a href="../../users/1500524/avinash" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1500524.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Avinash" /> </a> <div class="s-user-card--info"> <a href="../../users/1500524/avinash" class="s-user-card--link">Avinash</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,935</li> <li class="s-award-bling s-award-bling__gold" title="7 gold badges">7</li> <li class="s-award-bling s-award-bling__silver" title="29 silver badges">29</li> <li class="s-award-bling s-award-bling__bronze" title="55 bronze badges">55</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-46422083"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/46422083/unit-test-multiple-http-requests" class="question-hyperlink">Unit Test Multiple HTTP Requests</a></h3> <div class="excerpt">So in my factory I have a loop which requests HTTP calls and adds them to a promise array. I then do a $q.all on the result to build a model. When I come to test this however I can't get HTTP to make all the calls, it only makes the last one, I need…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/angularjs" class="post-tag grid--cell" title="show questions tagged 'angularjs'" rel="tag">angularjs</a> <a href="../../questions/tagged/unit-testing" class="post-tag grid--cell" title="show questions tagged 'unit-testing'" rel="tag">unit-testing</a> <a href="../../questions/tagged/jasmine" class="post-tag grid--cell" title="show questions tagged 'jasmine'" rel="tag">jasmine</a> <a href="../../questions/tagged/mocking" class="post-tag grid--cell" title="show questions tagged 'mocking'" rel="tag">mocking</a> <a href="../../questions/tagged/httpbackend" class="post-tag grid--cell" title="show questions tagged 'httpbackend'" rel="tag">httpbackend</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 26 '17 at 09:02">asked Sep 26 '17 at 09:02</time> <a href="../../users/580128/brokeneyes" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/580128.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="BrokenEyes" /> </a> <div class="s-user-card--info"> <a href="../../users/580128/brokeneyes" class="s-user-card--link">BrokenEyes</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">192</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badges">2</li> <li class="s-award-bling s-award-bling__bronze" title="18 bronze badges">18</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-44461001"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>0</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/44461001/angular2-httpbackend-mocking-rest-request" class="question-hyperlink">Angular2 httpbackend mocking REST request</a></h3> <div class="excerpt">I'm strugling trying to run a simple example of backend mocking REST request in angular2. After a few days facing many issues getting the instance of "httpbackend" object i found these guidelines.…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/rest" class="post-tag grid--cell" title="show questions tagged 'rest'" rel="tag">rest</a> <a href="../../questions/tagged/angular" class="post-tag grid--cell" title="show questions tagged 'angular'" rel="tag">angular</a> <a href="../../questions/tagged/mocking" class="post-tag grid--cell" title="show questions tagged 'mocking'" rel="tag">mocking</a> <a href="../../questions/tagged/backend" class="post-tag grid--cell" title="show questions tagged 'backend'" rel="tag">backend</a> <a href="../../questions/tagged/httpbackend" class="post-tag grid--cell" title="show questions tagged 'httpbackend'" rel="tag">httpbackend</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 09 '17 at 14:59">asked Jun 09 '17 at 14:59</time> <a href="../../users/8115064/gustavo-coelho" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/8115064.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Gustavo Coelho" /> </a> <div class="s-user-card--info"> <a href="../../users/8115064/gustavo-coelho" class="s-user-card--link">Gustavo Coelho</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">31</li> <li class="s-award-bling s-award-bling__bronze" title="3 bronze badges">3</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-43818576"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/43818576/protractor-browser-addmockmodule-is-not-executing-in-cucumber" class="question-hyperlink">Protractor : browser.addMockModule is not executing in cucumber</a></h3> <div class="excerpt">I have protractor with cucumber step-up and unable to mock $http call using browser.addMockModule step definition var {defineSupportCode} = require('cucumber'); defineSupportCode(function ({ Given, When, Then, setDefaultTimeout, …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/angularjs" class="post-tag grid--cell" title="show questions tagged 'angularjs'" rel="tag">angularjs</a> <a href="../../questions/tagged/protractor" class="post-tag grid--cell" title="show questions tagged 'protractor'" rel="tag">protractor</a> <a href="../../questions/tagged/cucumberjs" class="post-tag grid--cell" title="show questions tagged 'cucumberjs'" rel="tag">cucumberjs</a> <a href="../../questions/tagged/httpbackend" class="post-tag grid--cell" title="show questions tagged 'httpbackend'" rel="tag">httpbackend</a> <a href="../../questions/tagged/angular-mock" class="post-tag grid--cell" title="show questions tagged 'angular-mock'" rel="tag">angular-mock</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked May 06 '17 at 08:55">asked May 06 '17 at 08:55</time> <a href="../../users/1409676/abhishek-shukla" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1409676.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Abhishek Shukla" /> </a> <div class="s-user-card--info"> <a href="../../users/1409676/abhishek-shukla" class="s-user-card--link">Abhishek Shukla</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">646</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="8 silver badge">8</li> <li class="s-award-bling s-award-bling__bronze" title="21 bronze badge">21</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-43415446"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>0</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/43415446/php-cannot-open-text-file-on-network-drive" class="question-hyperlink">php cannot open text file on network drive</a></h3> <div class="excerpt">I have written a PHP script to create a text file on a network drive in 'write' mode, but for some reason, the text file cannot be created. Here's the original script: <?php error_reporting(E_ALL); ini_set('display_errors', 1); $myfile =…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/network-drive" class="post-tag grid--cell" title="show questions tagged 'network-drive'" rel="tag">network-drive</a> <a href="../../questions/tagged/httpbackend" class="post-tag grid--cell" title="show questions tagged 'httpbackend'" rel="tag">httpbackend</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 14 '17 at 16:24">asked Apr 14 '17 at 16:24</time> <a href="../../users/6909563/lingping-zeng" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/6909563.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Lingping Zeng" /> </a> <div class="s-user-card--info"> <a href="../../users/6909563/lingping-zeng" class="s-user-card--link">Lingping Zeng</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">41</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-43371879"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/43371879/mocking-apis-for-angular-app-component-testing" class="question-hyperlink">Mocking APIs for angular app component testing</a></h3> <div class="excerpt">Currently my team and I are facing an issue with our testing strategy.. We have our mocks set up in a completely inefficient way and need to find a better solution. Currently what we do is create a JSON file, often copied from the network traffic on…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/angularjs" class="post-tag grid--cell" title="show questions tagged 'angularjs'" rel="tag">angularjs</a> <a href="../../questions/tagged/testing" class="post-tag grid--cell" title="show questions tagged 'testing'" rel="tag">testing</a> <a href="../../questions/tagged/mocking" class="post-tag grid--cell" title="show questions tagged 'mocking'" rel="tag">mocking</a> <a href="../../questions/tagged/httpbackend" class="post-tag grid--cell" title="show questions tagged 'httpbackend'" rel="tag">httpbackend</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 12 '17 at 14:05">asked Apr 12 '17 at 14:05</time> <a href="../../users/2903882/tree55topz" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2903882.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Tree55Topz" /> </a> <div class="s-user-card--info"> <a href="../../users/2903882/tree55topz" class="s-user-card--link">Tree55Topz</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,102</li> <li class="s-award-bling s-award-bling__gold" title="4 gold badges">4</li> <li class="s-award-bling s-award-bling__silver" title="20 silver badges">20</li> <li class="s-award-bling s-award-bling__bronze" title="51 bronze badges">51</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/httpbackend_page=5" rel="prev" title="Go to page 5">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/httpbackend_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/httpbackend_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/httpbackend_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/httpbackend_page=14" rel="" title="Go to page 14">14</a> <a class="s-pagination--item" href="../../questions/tagged/httpbackend_page=15" rel="" title="Go to page 15">15</a> <a class="s-pagination--item" href="../../questions/tagged/httpbackend_page=7" rel="next" title="Go to page 7"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>