首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在容器化服务器上运行容器化Cypress runner?

如何在容器化服务器上运行容器化Cypress runner?
EN

Stack Overflow用户
提问于 2021-07-14 01:04:17
回答 1查看 45关注 0票数 0

我正在尝试对容器化的Nginx运行Cypress测试:

代码语言:javascript
复制
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                       NAMES
7c3efd24e6e6   tdd_nginx      "/docker-entrypoint.…"   19 minutes ago   Up 19 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp           tdd_nginx_1

从官方docs中我了解到我可以使用docker run -it -v $PWD:/e2e -w /e2e -e CYPRESS_baseUrl=host.docker.internal cypress/included:7.7.0

我了解到了host.docker.internal,据说Cypress知道如何在特定的容器中查找localhost

Nginx容器公开了80端口,所以我尝试了-e CYPRESS_baseUrl=host.docker.internal:80,并且没有指定端口,因为在大多数情况下,80端口是一个备用端口。

错误输出:

代码语言:javascript
复制
Cypress could not verify that this server is running:

  > http://host.docker.internal:80

We are verifying this server because it has been configured as your `baseUrl`.

Cypress automatically waits until your server is accessible before running tests.

We will try connecting to it 3 more times...
We will try connecting to it 2 more times...
We will try connecting to it 1 more time...

Cypress failed to verify that your server is running.

Please start this server and then run Cypress again.

将环境变量移到cypress.json中并没有什么不同:

代码语言:javascript
复制
{
  "baseUrl": "host.docker.internal",
  "video": false
}
EN

回答 1

Stack Overflow用户

发布于 2021-07-14 01:20:10

cypress.json更改为:

代码语言:javascript
复制
{
  "CYPRESS_BASE_URL": "host.docker.internal",
  "video": false
}

CYPRESS_BASE_URL解析为环境变量无济于事,但将其放入文件中确实起到了作用。奇怪的是,这会带来不同的结果。

感谢@jonrsharpe

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68366645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档