在花了一天半的代码争夺之后,我意识到e2e测试被绞死了,因为我已经手动引导并且没有使用ng-app指令
首先,仅供参考.
第二,任何想法为什么?怎么修好?
谢谢
利奥尔
–
编辑:这是两个显示它的蠢事,使用phone-cat教程示例:
适用于浏览器和e2e:
http://plnkr.co/edit/AfLsug1LRi0euKf7TWJa
在浏览器中以交互方式工作,在e2e runner中不起作用:
http://plnkr.co/edit/20OeZ5eV2ZbzgS1qDYfr
解决方法
Scenario runner似乎需要获得ng-app(对于$injector).我改编了
the fix identified here by Vojta Jína,它对我有用.
$(function() { var myApp = $('#appId'); // Use whatever selector is appropriate here. angular.bootstrap(myApp,[modules]); // modules is optional - see http://docs.angularjs.org/api/angular.bootstrap myApp.addClass('ng-app'); // Adds the required ng-app });
此外,您可能需要在beforeAll中暂停或等待,以便有足够的时间完成手动引导,例如,
beforeEach(function() { browser().navigateTo('../../index.html'); pause(); });
这个修复工作,但它不是那么令人满意的imho.有没有办法摆脱暂停/等待?