cypress-io / github-action

GitHub Action for running Cypress end-to-end & component tests
https://on.cypress.io/guides/continuous-integration/github-actions
MIT License
1.36k stars 339 forks source link

Error: connect ECONNREFUSED 127.0.0.1:5173 #1280

Open CaiqueCoelho opened 5 days ago

CaiqueCoelho commented 5 days ago

I'm trying to add a container image for cypress/browsers and setting browser as chrome to run Cypress tests in the GHA with cypress-io/github-action@v6 but I'm getting the following error

Error: connect ECONNREFUSED 127.0.0.1:5173

This is my config:

jobs:
  cypress-super-user:
    runs-on: ubuntu-20.04
    container:
      image: cypress/browsers:node-20.18.0-chrome-129.0.6668.89-1-ff-131.0.2-edge-129.0.2792.65-1
      options: --user 1001
    strategy:
      fail-fast: false
      matrix:
        containers: [1, 2, 3, 4]
    timeout-minutes: 180
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v4
        with:
          token: ${{ steps.generate_token.outputs.token }}
          submodules: recursive
          persist-credentials: false

      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: 20.18.0

      - name: Install Dependencies
        run: npm i

      - name: Run directory_ui
        run: npm run serve &

      - name: Cypress Tests 🧪
        uses: cypress-io/github-action@v6.7.6
        with:
          record: true
          parallel: true
          browser: chrome
          wait-on: "http://localhost:5173/"
          wait-on-timeout: 180
          env: userType=userSuperAdminType
          group: Raidiam - Super Admin
          config: baseUrl=http://localhost:5173

If I remove the container from the job Cypress is able to connect to 127.0.0.1:5173 and all tests pass

Additional Information: I'm using VUE version 2.7.14 and VITE version 5.4.6 Cypress version 13.15.0

MikeMcC399 commented 5 days ago

@CaiqueCoelho

You may find the README section Debugging helpful to look at what is going wrong in your workflow. There may be some timing differences between running directly in ubuntu-20.04 compared to running in a container using a Cypress cypress/browsers:node-20.18.0* Docker image, which is based on Debian 12.7.

You mention that you are using VUE version 2.7.14. According to https://v2.vuejs.org/eol/, Vue 2 reached end of life on Dec 31, 2023 and is no longer maintained.

MikeMcC399 commented 5 days ago

@CaiqueCoelho

Although I don't expect it to solve your issue, regarding the following section:

      - name: Install Dependencies
        run: npm i

      - name: Run directory_ui
        run: npm run serve &

if your repo contains a package-lock.json, then you may be able to replace these two steps using the start option. See the README documentation Start server.