angular - 如何在 Angular 应用程序的量角器测试中使用 NgZone
问题描述
我们有一个 Angular 应用程序,它使用一个运行时间很长的 HTTP 请求来等待来自服务器的事件。使用 Protractor 进行测试时,所有相关文章(例如:https://valor-software.com/articles/testing-with-protractor-how-to-fix-synchronization-issues.html和此处:https ://jarifibrahim。 github.io/blog/protractor-and-page-synchronization/)建议在 Angular 区域之外运行检查,否则 Protractor 会等待长 HTTP 请求完成并最终超时。但是,我不清楚,因为我还没有找到与此相关的完整 e2e 测试,如何在典型的 Angular Protractor 测试中注入 NgZone,包括一个页面对象和一个测试 (.spec.ts) 文件,如此处所述:https://coryrylan.com/blog/introduction-to-e2e-testing-with-the-angular-cli-and-protractor。我尝试以典型的 Angular 组件方式在 Page Object 类构造函数中导入 NgZone constructor(private ngZone: NgZone)
,但这不起作用。我错过了什么?
解决方案
推荐阅读
- android - Android C++异常抛出导致SIGSEGV
- angular - 如何等待对话材料响应以继续我的功能?
- python - 为什么在比较变量(对象?)时,python2 的输出与 python3 不同?
- razor - 模板无法接收 IList 模型
- java - 获取没有禁止api的进程输出
- arrays - 如何显示错误,包括单元格数组的内容
- etl - 自动将 CSV 文件移动到 talend ETL
- ios - UIPickerView 滚动到上一个项目时的奇怪行为
- asp.net-core - 如果 appsetings.json 中存在设置,为什么会忽略环境变量?
- javascript - 在表格行中不显示