简体   繁体   English

如何在 gitlab CI 上运行的同一端口上运行本地赛普拉斯测试?

[英]How to run locally Cypress test on the same port as they are run at gitlab CI?

My Cypress tests are run locally without any problem since they are run on the localhost:我的赛普拉斯测试在本地运行,没有任何问题,因为它们是在本地主机上运行的:

在此处输入图像描述

However, in Gitlab CI the Docker image is created with another IP address and therefore Cypress tests fail:但是,在 Gitlab CI 中,Docker 映像是使用另一个 IP 地址创建的,因此赛普拉斯测试失败:

在此处输入图像描述

How can I fix it?我该如何解决? Thanks谢谢

If I understand the question correctly you just have to change the URL you are visiting.如果我正确理解了这个问题,您只需更改您正在访问的 URL 即可。 In the cypress.json file try changing the baseURL to your desired entry point, in this case在 cypress.json 文件中,尝试将 baseURL 更改为所需的入口点,在这种情况下

    "baseUrl": "http://172.17.0.3/"

This way you can just这样你就可以

    cy.visit('/relativePathEtc') 

and will be prefixed with the baseUrl.并将以 baseUrl 为前缀。

Source: https://docs.cypress.io/api/commands/visit#Prefixes来源: https://docs.cypress.io/api/commands/visit#Prefixes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM