EDIT: I solved the problem by lowering angular -mocks to 1.3.x (I am using AngularJS 1.3.x)
I am learning to write and run a test in my Angular app with karma and jasmine.
The first tests passed, but when implementing $httpBackend I received the following error:
TypeError: $browser.cookies is not a function at sendReq (/typotheque-web/public/app/bower_components/angular/angular.js:9661:24) at serverRequest (/typotheque-web/public/app/bower_components/angular/angular.js:9383:16) at processQueue (/typotheque-web/public/app/bower_components/angular/angular.js:13248:27) at /typotheque-web/public/app/bower_components/angular/angular.js:13264:27 at Scope.$eval (/typotheque-web/public/app/bower_components/angular/angular.js:14466:28) at Scope.$digest (/typotheque-web/public/app/bower_components/angular/angular.js:14282:31) at Function.$httpBackend.flush (/typotheque-web/public/app/bower_components/angular-mocks/angular-mocks.js:1510:38) at Object.<anonymous> (/typotheque-web/public/test/libraryServiceSpec.js:74:17)
The incriminated part of the code ...
And the updateFonts() method:
this.updateFonts = function(callback) { return $http.get(BACKEND_URL+'/fonts') .success(function(data) { console.log('Library :: fonts updated', data); self.fonts = data; self.state.fonts.loaded = true; self.state.fonts.error = false; if(callback) callback(self.fonts); }).error(function() { self.state.fonts.error = true; }); };
When I delete this part, the tests pass fine. In any case, I referenced the angular-cookie library in my Karma configuration, but I still had an error.
I do not understand why I am getting this error, because I do not use cookies through the entire application .
javascript angularjs cookies karma-runner jasmine
ryancey
source share