I have a function in my Angular controller that looks like the following:
$scope.myFunction = function(){
$scope.myVariable = "something";
$scope.myOtherVariable = "something else";
window.location.href = "/path/to/page";
}
A simple Jasmine test covers the above function and looks like:
describe('my test', function(){
it('should pass', function(){
scope.myFunction();
expect(scope.myVariable).toBe('something');
expect(scope.myOtherVariable).toBe('something else');
});
});
The above test itself passes, but then Karma throws the following error in the console:
Some of your tests did a full page reload!
The page redirect is causing Karma to raise this warning. What's the best way to get around this?
I thought about giving both anonymous functions in the Jasmine test and Angular names and then using arguements.callee.caller.name inside the original function to determine whether the function is being called by itself or Jasmine. Unfortunately, arguments.callee.caller.name always returns undefined, which I suspect is caused by the way Angular and Jasmine are linked to each other.