【发布时间】:2021-02-07 18:57:28
【问题描述】:
我有一组 cypress e2e 测试。这些测试的代码位于他们自己的 git 存储库中。
通过 cypress cli 手动执行这些测试时,我可以根据环境 DEV/QA/STG 和 PROD 访问不同的 URL。
我可以在本地运行应用程序,但我不想这样做,我想做的是在容器内执行测试并让它们访问容器外的应用程序。
在尝试完成此操作时,我已在端口 4200 上本地启动应用程序。我的 cypress 配置在其配置文件中设置了基本 url 属性,我可以从 Cypress cli(不在 docker 中)成功运行测试。
在我的 cypress 测试仓库中,我有以下 Dockerfile
FROM cypress/base:12.18.4
RUN mkdir /app
WORKDIR /app
COPY . /app
RUN npm install
RUN $(npm bin)/cypress verify
RUN ["npm","run","cypress:run"]
执行docker run我看到以下错误。
#12 6.411 Cypress could not verify that this server is running:
#12 6.411
#12 6.411 > http://localhost:4200/
#12 6.411
#12 6.411 We are verifying this server because it has been configured as your `baseUrl`.
#12 6.411
#12 6.411 Cypress automatically waits until your server is accessible before running tests.
#12 6.411
#12 6.411 We will try connecting to it 3 more times...
#12 9.417 We will try connecting to it 2 more times...
#12 12.42 We will try connecting to it 1 more time...
#12 12.42
#12 16.43 Cypress failed to verify that your server is running.
不完全确定如何“允许”测试联系我的localhost:4200
感觉我需要创建一个 docker-compose 文件,但不确定网络细节。
非常感谢任何帮助或想法
【问题讨论】:
标签: docker docker-compose cypress