mc.*_*cki 8 cucumber protractor e2e-testing angular angular-e2e
我正在尝试使用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'
});
}
};
Run Code Online (Sandbox Code Playgroud)
简而言之 - 测试使用以下配置运行,但是当我删除时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
对象ng serve
我使用的是最新版本的Protractor,Cucumber,Chai和TypeScript.任何帮助将非常感激.非常感谢你提前!
这听起来像是一个潜在的Zone问题.角度取决于ZoneJS(ngZone).这并不是说鲜见使用任何异步JavaScript功能,例如,当运行到这个错误setTimeout()
,setInterval()
等...
原因是ZoneJS猴子修补了这些功能,并且它是在Angular区域的上下文中完成的.当Protractor尝试连接到您的应用程序时,它不再在Angular Zone中运行,因此Protractor将挂起并最终因您收到的错误而超时.
如果我是你,我会看看你的应用程序是否有ZoneJS猴子补丁的任何异步功能.通常,在代码中查找在应用程序区域的上下文之外运行的任何内容.
这是一篇关于ZoneJS的好文章,它不仅可以帮助您理解ZoneJS,还列出了猴子修补的功能了解ZoneJS
归档时间: |
|
查看次数: |
965 次 |
最近记录: |