Folks
I have a jasmine-karma unit test setup for my angular app. The issue is in my app.js defined module.ru, this method is calling a custom service (LoginService) that in turns calls a $http service. The issue I'm having here is, I am testing my LoginService and mocking the $http service, when I try to flush, it throws error:
Error: Unexpected request: GET /frontend/login
No more request expected
I believe this extra request is coming from the module.run.
app.run(['LoginService',function(LoginService){
LoginService.checkLoginStatus().then(function(status){
console.log(status);
}, function(status){
console.log(false);
});
}]);
This is my plunkr code: http://plnkr.co/edit/f9bEH1fNTxDoxvWfajH5
My issue was that, in my unit test, I was bootstrapping the entire app
beforeEach(module("app")).
Once I segmented my controllers, directives and services into their own module
beforeEach(module("app.controllers"))
beforeEach(module("app.directives"))
beforeEach(module("app.services"))
Then I no longer faced the issue. The test I had configured wasn't unit testing but, was e2e testing.