jeudi 3 mars 2016

$rootScope.$apply in jasmine test triggers http GET from module

I have a Jasmine unit test that is testing an Angular controller whereby a function returns a promise and populates a controller field with the results of the promise. I'm testing this to check that the field gets populated and calling $rootScope.$apply to resolve the promise and set the value.

When the $rootScope.$apply is called I get an error due to a module attempting to GET a json file in its config setup.

Karma shows the error t be related to $hhtpBackend and comes from angular-mocks.js

Error: Unexpected request: GET /languages/en.json
No more request expected
       at $httpBackend (c:\dev\myapp\scrips\angular-mocks.js:1244:17)
       at sendReq (c:\dev\myapp\scripts\angular.js)
       at serverRequest (c:\dev\myapp\scripts\angular.js)
       at Scope.$eval
       at Scope.$digest
       at Scope.$apply

Aucun commentaire:

Enregistrer un commentaire