1

我已经搜索了文档和谷歌,并且正在努力寻找关于应该如何为ngMouseenter事件编写 E2E 测试的可靠参考。element(<selector>).click()据我所知,Angular 的 E2E 测试工具对于其他事件类型一无所获。

在我的例子中,mouseenter(和 mouseleave)触发了我想要继续测试的行为,我想其他人也有类似的用例。有没有办法做到这一点?

[编辑]

我在 SO 上找到了 Angular 的场景运行器的扩展:AngularJS:如何调用事件处理程序并检测测试中的绑定

这允许我这样做:

jqFunction(<selector>, "mouseenter")

效果很好。

4

2 回答 2

1

在 angular github 上,有一个pull request已在此处mouseover合并到 v1.1.2 中。也许这会有所帮助?

否则,只要您可以使用 jQuery 触发事件,您应该能够执行类似的操作

element(<selector>).query(function(selected, done) {
    selected.trigger('mouseenter');
    done();
});

对于任何自定义事件。话虽如此,我已经尝试在 plunker 中进行测试,并且似乎根本无法mouseenter触发,无论是否涉及角度。

于 2013-10-12T03:50:12.157 回答
1

ng-mouseenter指令在内部建立在mouseover事件之上。要触发它,只需调用

yourElement.trigger('mouseover');

另请参阅此问题

于 2014-11-09T16:01:37.750 回答