You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Actions中Cypress无法找到Vagrant部署的IPA服务器

问题:Cypress无法连接Vagrant部署的IPA服务器

我在Vagrant部署的ipa服务器上运行cypress测试,已将Vagrant的IP写入GitHub Runner使用的/etc/hosts文件,但cypress始终无法找到运行中的服务器。

约一个月前,Runner使用192.168.x.y段IP,Vagrant配置的静态地址能正常被Cypress识别;近期Vagrant配置的地址变为10.0.x.y段后,问题出现。

已尝试的解决方法

  • 为Cypress配置的baseUrl参数分别设置http和https
  • 在Cypress步骤中通过env参数设置带有IP的host(详见PR中的gating.yml)
  • 在gating.yml中使用wait-on等待服务器地址server.ipa.demo

相关代码

cypress.config.ts

e2e: {
    specPattern: "**/*.feature",
    baseUrl: "http://server.ipa.demo",

gating.yml

- name: Cache Vagrant boxes
        uses: actions/cache@v3
        with:
          path: ~/.vagrant.d/boxes
          key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
          restore-keys: |
            ${{ runner.os }}-vagrant-

      - name: Cleanup running Vagrant boxes in case they are running
        run: vagrant destroy --force

      - name: Run vagrant up
        run: vagrant up --no-provision

      - name: Run vagrant provision
        run: vagrant provision

      - name: Put IPA Server's IP to /etc/hosts
        run: sudo echo "$(vagrant ssh -c "hostname -I") server.ipa.demo" | sudo tee -a /etc/hosts

      - name: Save server's IP address to env
        run: echo "SERVER_IP=$(vagrant ssh -c "hostname -I")" >> $GITHUB_ENV

      - name: Print exported variable
        run: echo "$SERVER_IP"

      - name: Run Cypress tests
        uses: cypress-io/github-action@v6
        with:
          browser: firefox
          env: host="https://${{ env.SERVER_IP  }}"

报错信息

Cypress could not verify that this server is running:

  > https://server.ipa.demo/

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...

内容的提问来源于stack exchange,提问作者Michal Polovka

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 21:36:31