I am getting this error when I do the following test:
it(\'should call pauseAnimationInterval if in focus\', inject(function(SearchBoxData, intervalManager, $ti
Scope events which are $broadcast()'d or $emit()'d are synchronous, and return the event object when they're finished.
Some things in Angular depend on the returned event object, such as ngRoute.
So what you can do to fix this is simply add andCallThrough()
when you create your spy, so that it calls the original function and yields a return value.
Alternatively, if you don't want to use the real $broadcast, you can use andCallFake()
to supply a fake function which can return anything you want.
Example:
beforeEach(function(){
module('MyApp');
inject(function($injector){
rootScope = $injector.get('$rootScope');
spyOn(rootScope,'$broadcast').andCallThrough(); // will prevent the reference error
})
});