【发布时间】:2015-09-01 06:48:40
【问题描述】:
您如何使用外部库(例如谷歌分析事件跟踪)测试角度控制器。例如:
$scope.showVolumn = function() {
ga('send', {
'hitType': 'event',
'eventCategory': 'Volume',
'eventAction': 'click',
'eventLabel': 'Interaction'
});
if($scope.native !== 'true')
vm.showVolumnCtl = !vm.showVolumnCtl;
};
运行以为我的测试代码出现了这个错误
ReferenceError:找不到变量:ga
我认为你不能在 beforeEach 中注入 ga 对吧?
【问题讨论】:
标签: javascript angularjs unit-testing