How to test on destroy scope
问题 How to unit testing an $destroy event of a Directive in angularjs? I have the code in my directive: scope.$on('$destroy', function () { //clean something }); My test code: it('on destroy',function(){ scope.$destroy(); scope.$digest(); //expect everything done? }); Any suggestion! 回答1: You can select the DOM from the template of your directive and get the scope of it, then run $destroy(). Ex: your tpl: "<div id='tuna'></div>" your test: it('test on destroy', function(){ var isolateScope = $