草庐IT

javascript - 失败 : Timed out waiting for asynchronous Angular tasks to finish after 11 seconds

coder 2024-05-05 原文

我想使用 Protractor 对我们的 Angular 2 应用程序进行端到端测试,但我仍然坚持消息:

"Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds."

我的配置文件。

exports.config = {
  directConnect: true,
  specs: ['spec.js'],

  // For angular2 tests
  useAllAngular2AppRoots: true,
}

Chrome打开了,网站也打开了,然后直到超时什么都没有。

禁用同步时(使用 browser.ignoreSynchronization = true; ),没关系。但我正在失去“自动等待”功能,这是使用 Protractor 的主要优势之一。

该应用程序完全基于 Angular 2。那么为什么这行不通呢?

我们的开发人员告诉我我们没有轮询(根据 Protractor documentation 可能的原因之一)。 顺便说一下,我们使用的是 websocket 架构。不知道有没有链接。

其实我根本不知道怎么解决这个问题。

有人可以帮忙吗?

最佳答案

你猜对了。当它们是在您的 angular2 应用程序中运行的任何未完成任务时,就会发生此错误。

是的,最常见的原因是当应用程序连续轮询 $timeout 或 $http 时,Protractor 将无限期地等待并超时。但是在App耗时超过11秒的场景下也会出现这种情况

请引用here有关不同超时的更多信息

默认超时值为 11 秒。您可以通过调整以下值来更改 config.js并尝试看看您是否仍然看到问题

  /**
   * The timeout in milliseconds for each script run on the browser. This
   * should be longer than the maximum time your application needs to
   * stabilize between tasks.
   */
  allScriptsTimeout?: number;

关于javascript - 失败 : Timed out waiting for asynchronous Angular tasks to finish after 11 seconds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41285341/

有关javascript - 失败 : Timed out waiting for asynchronous Angular tasks to finish after 11 seconds的更多相关文章

随机推荐