There are several ways to do this:
1.) Include before Tim Castellins suggested, but for each specification file 2.) Include beforeEach in a separate file called app-mocks.js and include in your karma.conf.js (I assume you have) .
karma.conf.js
files: [
'location/of/app-mocks.js',
'src/app/**/*.js'
],
application-mocks.js
(function () {
'use strict';
beforeEach(inject(function ($httpBackend) {
$httpBackend.whenGET('blahblahblah.com/cat/:id/food').respond('');
}));
})();
3.) Separate the user authentication logic from the main application and create the $ http wrapper service ( proposed ). So you can have (simplified example):
app.js
angular.module('myApp', ['myApp.services']);
custom service.js
angular.module('myApp.services', [])
.factory('User', function ($http) {
function authenticate() {
}
return {
authenticate: authenticate
};
});
, .. , unit test , , . , , . , . , , :
beforeEach(module('myApp.services'));
beforeEach(module('myApp.directives'));
.
. , , , .