Angularjs 因果报应测试在指令中失败

Angularjs 因果报应测试在指令中失败,angularjs,karma-runner,karma-jasmine,Angularjs,Karma Runner,Karma Jasmine,我有以下指示。此指令将在动画结束触发后触发。我现在只想为这个指令添加测试。我已经为此创建了测试用例。但它失败了。有人能帮忙吗 我的测试用例是 describe('Directive: animationend', function () { // load the directive's module beforeEach(module('movieApp')); var elements, scope, compile; beforeEach(inject

我有以下指示。此指令将在动画结束触发后触发。我现在只想为这个指令添加测试。我已经为此创建了测试用例。但它失败了。有人能帮忙吗

我的测试用例是

describe('Directive: animationend', function () {

  // load the directive's module
  beforeEach(module('movieApp'));

  var elements,
    scope,
    compile;

  beforeEach(inject(function ($rootScope, _$compile_) {
    scope = $rootScope.$new();
    compile = _$compile_;
    elements = angular.element('<div animationend="" ></div>');
    elements = compile(elements)(scope);
    scope.$digest();
  }));

  it('should trigger the callback once animationclass is added ', function () {

    scope.ctrl = {
      animationend: jasmine.createSpy('animationend')
    };
    scope.$digest();
    var events = 'animationend webkitAnimationEnd MSAnimationEnd' +
                        'transitionend webkitTransitionEnd';
    angular.element(elements).triggerHandler(events);
    // element.trigger(events);
    expect(scope.ctrl.animationend).toHaveBeenCalled();
  });


});
descripe('指令:animationend',函数(){
//加载指令的模块
每个模块之前(模块(“movieApp”);
var元素,
范围
编撰;
beforeach(注入(函数($rootScope,$compile){
scope=$rootScope.$new();
compile=\$compile;
元素=角度。元素(“”);
元素=编译(元素)(范围);
范围。$digest();
}));
它('应在添加animationclass后触发回调',函数(){
scope.ctrl={
animationend:jasmine.createSpy('animationend'))
};
范围。$digest();
变量事件='animationend webkitAnimationEnd MSAnimationEnd'+
“transitionend和WebKittTransitionEnd”;
angular.element(元素).triggerHandler(事件);
//元素。触发器(事件);
expect(scope.ctrl.animationend).toHaveBeenCalled();
});
});
describe('Directive: animationend', function () {

  // load the directive's module
  beforeEach(module('movieApp'));

  var elements,
    scope,
    compile;

  beforeEach(inject(function ($rootScope, _$compile_) {
    scope = $rootScope.$new();
    compile = _$compile_;
    elements = angular.element('<div animationend="" ></div>');
    elements = compile(elements)(scope);
    scope.$digest();
  }));

  it('should trigger the callback once animationclass is added ', function () {

    scope.ctrl = {
      animationend: jasmine.createSpy('animationend')
    };
    scope.$digest();
    var events = 'animationend webkitAnimationEnd MSAnimationEnd' +
                        'transitionend webkitTransitionEnd';
    angular.element(elements).triggerHandler(events);
    // element.trigger(events);
    expect(scope.ctrl.animationend).toHaveBeenCalled();
  });


});