1

Hi I am requesting a JSON file from an external URL https://...json.

When running my tests it causes an unexpected error even though I did not write any tests on my functions yet. Only the tests for my controller fail (at the $scope.$digest()).

My code looks as follows

Service:

angular.module('myApp').service('dealService',['$http','$location',function($http,$location){
  this.deals = function () {
    return $http({
      method: 'GET',
      url: 'https://myurl.com/deals.json'
    }).then(function (response) {
      return response.data;
    });
  };
}]);

This returns an array which I then take as promise such as Controller:

$scope.dealsLanding = [];
        dealService.deals().then(function (deals) {
          $scope.dealsLanding = deals;
        });

This however seems to cause my tests to fail. Error: Unexpected request: GET https://myurl.com/deals.json No more request expected.

What can I do about it?

Dribel
  • 465
  • 1
  • 10
  • 24
  • This looks like this angular error: http://stackoverflow.com/a/18148691/16959 – Jason Sperske Jun 15 '15 at 10:55
  • This may help you : http://stackoverflow.com/questions/19779528/unexpected-request-get-no-more-request-expected-at-httpbackend – Anjum Jun 15 '15 at 10:59
  • Thanks for the quick responses. I read those articles, but why do these functions mess with my tests even though I do not even touch them? – Dribel Jun 15 '15 at 11:04

0 Answers0