Cypress override baseUrl in Docker container not working

Viewed 597

Hello Im looking for help.| I have a docker image that builds my Cypress tests in which I would like to override the baseURL. The problems is Cypress detects the baseUrl env variables but it doesn't apply them to the configuration and baseUrl still points to the localhost.

docker run \
      --name test \
      --env CI="true" \
      --env CYPRESS_BASE_URL="https://abrakada.com" \
      --env CYPRESS_baseUrl="https://abrakada.com" \
      --network="host" \
      --rm
FROM cypress/base:14.17.0

ARG TESTS_FOLDER=/opt/cypress-tests

ENV NODE_PATH=/opt:/usr/lib/node_modules:$TESTS_FOLDER/node_modules

WORKDIR $TESTS_FOLDER

COPY package.json ./package.json

RUN npm install && npm run cy:verify

COPY cypress.json ./cypress.json
COPY cypress ./cypress

ENTRYPOINT ["npm", "run", "cy:integration"]

{
  "baseUrl": "http://localhost:3000",
  "chromeWebSecurity": false,
  "screenshotOnRunFailure": false,
  "videoUploadOnPasses": false
}

> npm run cy:info && ./node_modules/.bin/cypress run


> app-tests@1.0.0 cy:info /opt/cypress-tests
> cypress info

Displaying Cypress info...

Detected no known browsers installed


Environment Variables:
CYPRESS_BASE_URL: https://abrakada.com
CYPRESS_baseUrl: https://abrakada.com

Application Data: /root/.config/cypress/cy/development
Browser Profiles: /root/.config/cypress/cy/development/browsers
Binary Caches: /root/.cache/Cypress

Cypress Version: 8.1.0
System Platform: linux (Debian - 10.9)
System Memory: 6.23 GB free 389 MB
Cypress could not verify that this server is running:

  > http://localhost:3000

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

1 Answers

fsss I hate it. Like always after few hours of troubleshooting I post a question and then after 15 min of the post I find the problem... Gosh..

Anyway.

My problem was that I had plugins configuration for extending config file which caused rest of configuration not being merged.

https://github.com/bahmutov/cypress-extends

replaced return require('@bahmutov/cypress-extends')(config.configFile) with just config and baseUrl is being overwritten.

Related