首页 > 解决方案 > 如何配置赛普拉斯等待更长时间(或无限期)BaseUrl?

问题描述

我正在使用这个赛普拉斯图像docker-compose.yml来运行端到端测试:cypress/included:6.1.0

当测试运行程序启动时,它将验证是否可以在baseUrl. 如果没有,它会重试 3 次。

我的服务和 Web 服务器需要更多时间才能启动。

如何增加此检查的超时和/或重试次数。

最好,在我的情况下,我想要一个重试直到成功的策略,即无限期重试/等待。

我已经更普遍地检查了超时部分和cypress.json文档。但是,这些超时或重试似乎都与此行为无关。

有这个设置吗?


澄清:这不是我实施(或想要)作为我规范的一部分的检查。据我所知,这是cyprus run图像中默认命令的一个特性。如果可能的话,我想在不添加或修改测试本身的情况下对其进行配置。

这是 cypress 在容器中启动时的 docker-compose 控制台输出:

cypress_1         | Cypress could not verify that this server is running:
cypress_1         |
cypress_1         |   > http://localhost:5000
cypress_1         |
cypress_1         | We are verifying this server because it has been configured as your `baseUrl`.
cypress_1         |
cypress_1         | Cypress automatically waits until your server is accessible before running tests.
cypress_1         |
cypress_1         | We will try connecting to it 3 more times...
cypress_1         | We will try connecting to it 2 more times...
cypress_1         | We will try connecting to it 1 more time...
cypress_1         |
cypress_1         | Cypress failed to verify that your server is running.
cypress_1         |
cypress_1         | Please start this server and then run Cypress again.
cypress_1 exited with code 1

标签: javascriptautomated-testscypressend-to-end

解决方案


cypress run在使用诸如wait-onstart-server-and-test 之类的实用程序调用之前,您应该确保您的服务器正在运行。

Cypress 的检查baseUrl是最后的礼貌检查,这样您就不会在未运行的服务器上运行整个测试套件。

有关在运行赛普拉斯之前确保服务器正在运行的提示,请在此处查看赛普拉斯文档:https ://on.cypress.io/continuous-integration#Boot-your-server


推荐阅读