我有一个简单的端到端测试,以验证路由重定向作品
I have a simple e2e test to verify that route redirection works
<!doctype html>
<html lang="en">
<head>
<title>End2end Test Runner</title>
<script src="../client/components/angular-scenario/angular-scenario.js" ng-autotest></script>
<script src="e2e/scenarios.js"></script>
</head>
<body>
</body>
</html>
'use strict';
describe('e2e', function() {
beforeEach(function() {
browser().navigateTo('../../client/index.html');
});
it('should redirect to the main application home page with / is accessed', function() {
browser().navigateTo('#!/');
expect(browser().location().path()).toBe('/app');
});
});
*snip*
files = [
ANGULAR_SCENARIO,
ANGULAR_SCENARIO_ADAPTER,
'./test/e2e/**/*.js',
];
*snip*
在此被运行,浏览器()位置()路径()将引发一个异常:
When this gets run, browser().location().path() will raise an exception:
TypeError: 'undefined' is not a function (evaluating '$document.injector()')
我已经确定了它的。路径()在这是造成问题,因为如果我这样做的浏览器()。位置()不会引发异常结束。
I've determined it's the .path() at the end that's causing the issue since if I do browser().location() no exception is raised.
然而,在浏览器控制台,这将返回一个angular.scenario.Future预期。
However in the browsers console this will return a angular.scenario.Future as expected.
为什么一个异常被提出?
Why is an exception being raised?
从我的头顶,这里有AngularJS端到端的最主要原因测试不工作
From the top of my head, here are the top reasons for AngularJS E2E tests not working
的AngularJS端到端测试,需要你有你的应用程序的HTML定义的NG-应用。如果手动白手创业,你需要将它自己加入 - 谷歌论坛讨论 确保您的代理正确定义,并确保您可以直接导航到它。在browser.navigateTo(右后您的测试中添加暂停()),并确保应用程序实际上是装载在AngularJS方案Runner在浏览器中。调试最后一步,你得到的浏览器位置之前添加一个睡眠2到三秒钟。这可能是该angularJS喷油器不能正确地传达给你的AngularJS应用程序,从而导致它无法等待所需的时间。这些希望有做的伎俩为您服务!
Hope one of these does the trick for you!