您好,我正在寻求帮助。| 我有一个构建我的 Cypress 测试的 docker 镜像,我想在其中覆盖 baseURL。问题是 Cypress 检测到了 baseUrl 环境变量,但它没有将它们应用到配置中,并且 baseUrl 仍然指向本地主机。
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
> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c6a7b6b6ebb2a3b5b2b586f7e8f6e8f6" rel="noreferrer noopener nofollow">[email protected]</a> 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`.
最佳答案
fsss我讨厌它。像往常一样,经过几个小时的故障排除后,我发布了一个问题,然后在发布 15 分钟后我发现了问题......天哪......
无论如何。
我的问题是我有用于扩展配置文件的插件配置,这导致其余配置未合并。
https://github.com/bahmutov/cypress-extends
已替换
返回 require('@bahmutov/cypress-extends')(config.configFile)
仅使用 config
和 baseUrl 被覆盖。
关于javascript - Cypress 覆盖 Docker 容器中的 baseUrl 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68833006/