basePath = '../htdocs';
files = [
JASMINE,
JASMINE_ADAPTER,
//bunch more includes, note I am using angular-mocks
];
autoWatch = false;
browsers = ['Chrome','Firefox','Safari'];
singleRun = true;
describe('Desktop Controller', function(){
var scope, $controller, controllerOptions, $httpBackend, callback, unitTestMocker;
beforeEach(module('of'));
beforeEach(module('unitTestMocker'));
beforeEach(inject(function($injector, $rootScope) {
$httpBackend = $injector.get('$httpBackend');
callback = jasmine.createSpy();
scope = $rootScope.$new();
$controller = $injector.get('$controller');
unitTestMocker = $injector.get('unitTestMocker');
controllerOptions = {
$scope: scope
};
$httpBackend.when('GET', /\.html$/).passThrough();
}));
afterEach(function() {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
it('should have basic elements', function() {
unitTestMocker.setValidLoadSessionResponse();
var controller = new $controller('DesktopCtrl', controllerOptions);
unitTestMocker.flush();
//make sure the session data got loaded
expect(scope.session.get('user').firstName).toEqual('Good');
expect(scope.session.get('user').lastName).toEqual('User');
});
});
The issue is that I get the error passThrough() is not a method and that would only happen according to the angular source code if $browser does not get set. I though that running the unit tests like I am (specifying the specific browsers) would get the $browser defined since I though the test were executed in actual browsers. Should I not have access to passThrough() in unit tests with karma?