Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseUrl in cypress.config.ts won't get overwritten by setting CYPRESS_baseUrl or CYPRESS_BASE_URL #29556

Open
Baluditor opened this issue May 22, 2024 · 2 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period

Comments

@Baluditor
Copy link

Current behavior

I have the following cypress.config.ts:

import { defineConfig } from 'cypress';

export default defineConfig({
  e2e: {
    experimentalModifyObstructiveThirdPartyCode: true,
    baseUrl: 'http://localhost:3000',
  },

  component: {
    devServer: {
      framework: 'react',
      bundler: 'vite',
    },
  },

  env: {
    baseUrl: 'http://localhost:3000',
    authUrl: 'https://localhost:4013',
    ... 
  },
});

and my test.yml file:

name: Run tests
on: [pull_request]

jobs:
  cypress-e2e-run:
    name: Cypress E2E tests
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: add deployment configuration for main branch
        run: |
          cat testing.env.conf >> $GITHUB_ENV

      - name: Cypress E2E tests
        uses: cypress-io/github-action@v6
        with:
          browser: chrome
        env:
          CYPRESS_userName: ${{ secrets.CYPRESS_USER_NAME_TESTING }}
          CYPRESS_password: ${{ secrets.CYPRESS_PASSWORD_TESTING }}
          # I tried with CYPRESS_AUTH_URL and CYPRESS_BASE_URL, same result
          CYPRESS_authUrl: ${{ env.VITE_APP_AZURE_B2C_AUTHORITY }}
          CYPRESS_baseUrl: ${{ env.swa_preview_hostname_first_part }}-${{ github.event.pull_request.number }}.${{ env.swa_preview_hostname_second_part }}

My issue is that the baseUrl will be http://localhost:3000 no matter what I do.
I see that the env vars are set in Github Workflow:
image

According to the docs this should work.

Desired behavior

My expectations is that baseUrl overwritten.

Test code to reproduce

N/A

Cypress Version

Cypress package version: 13.8.1

Node version

Node version: 18.17.1

Operating System

ubuntu-22.04

Debug Logs

No response

Other

No response

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label May 24, 2024
@Baluditor
Copy link
Author

I've done some more testing and I found the following:

 # Base URL overwrite is somewhat working. Withouth it, the test would run agains the localhost. Setting it solves that issue, but accessing it with cypress.env('baseUrl') will still returns 'localhost'.
CYPRESS_baseUrl: ${{ env.swa_preview_hostname_first_part }}-${{ github.event.pull_request.number }}.${{ env.swa_preview_hostname_second_part }}
 # But baseUrl still can't be used in the tests, thus setting a hostUrl variable which will have the correct value.
CYPRESS_hostUrl: ${{ env.swa_preview_hostname_first_part }}-${{ github.event.pull_request.number }}.${{ env.swa_preview_hostname_second_part }}

So basically, I had the assumption that overwriting the baseUrl would affect the e2e baseUrl too, but this dosen't seem to work.

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period
Projects
None yet
Development

No branches or pull requests

3 participants