Trigger click event on an AngularJS directive in Mocha test suite

偶尔善良 提交于 2019-11-30 21:04:08

Turns out the problem was quite hidden.

Firstly the $scope.$digest and $scope.$apply functions broke the beforeEach function which ultimately led to the whole solution.

Solution

Do not mix angular versions.

That was the whole problem, and gave me quite obscure errors.

Thanks to Foxandxss from the #AngularJS IRC channel on freenode.


The way to trigger events on the directive with jQlite was simply:

someElement.triggerHandler('click');

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!