【发布时间】:2018-10-24 23:08:00
【问题描述】:
我正在尝试使用 Protractor 和 Cucumber 为我的 Web 应用程序创建一个包含 E2E 测试的存储库。我已经开始使用这个存储库:https://github.com/spektrakel-blog/angular-protractor-cucumber
当我强制 Protractor 将应用程序视为常规网页时,测试运行良好。测试运行程序正在与应用程序交互并期待一些结果。问题是,我想让 Protractor 检测 Angular,以便在检查“Then”断言之前等待区域稳定。
这是我的 protractor.conf.js:
exports.config = {
allScriptsTimeout: 30000,
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox']
}
},
directConnect: true,
baseUrl: 'http://<ci-server-address>/',
specs: [
'./e2e/features/*.feature'
],
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
require: ['./e2e/steps/**/*.ts'],
strict: true,
format: [
'json:reports/summary.json'
],
dryRun: false,
compiler: []
},
onPrepare() {
browser.ignoreSynchronization = true;
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
}
};
简而言之 - 测试使用以下配置运行,但是当我删除 browser.ignoreSynchronization = true; 时,我收到以下错误:Timed out waiting for asynchronous Angular tasks to finish after 30 seconds. This may be because the current page is not an Angular application.。
到目前为止我尝试过的事情(没有改进):
- 将
ng-app添加到<body>标记 - 检查
window.getAllAngularRootElements()- 正确返回app-root - 检查
window.getAllAngularTestabilities()- 返回一个Testability对象 - 在 Chrome 上启动测试(带或不带沙盒)
- 在 Firefox 上启动测试
- 尝试部署我们的应用程序的 CI 服务器和使用
ng serve的本地环境
我正在使用最新版本的 Protractor、Cucumber、Chai 和 TypeScript。任何帮助将非常感激。非常感谢您!
【问题讨论】:
-
您有工作解决方案并询问为什么其他一些事情没有工作,这很奇怪。为什么你不能只使用工作之一?您希望获得哪些优势?
-
我在哪里写到我有一个可行的解决方案?
-
When I am forcing Protractor to treat the application as a regular webpage, the tests run fine.这个。我只是想了解您是否尝试解决问题(当然,这是问题所在),但您可能会选择另一种方式。 -
当 Protractor 无法检测到 Angular 时,它无法等待解析区域。在这种情况下,我需要在我的 E2E 测试中设置超时以使它们通过。这是不可接受的,更不用说我正在使用 Protractor 因为 Angular 集成。 ;)
-
为什么你不能等
explicit服务员的zonez?
标签: angular protractor cucumber e2e-testing angular-e2e