unit test spy on $emit
I'm trying to spy on an $emit from a directive, but somehow I cannot get the spy to 'hear' the $emit. This is the code in my directives' controller: $scope.$on('send', function () { console.log('called'); $scope.$emit('resultSend', {'ok': true, 'data': ''}); }); This is my unit test: var $rootScope, $compile, elm, element; beforeEach(inject(function ($injector) { $rootScope = $injector.get('$rootScope'); $compile = $injector.get('$compile'); elm = angular.element('<test></test>'); element = $compile(elm)($rootScope); })); it('should listen for the send broadcast and emit the resultSend',