首页 > 解决方案 > cypress 测试套件是否有办法在其输出中取消屏蔽敏感信息以进行调试?

问题描述

背景:我正在尝试在 Circle CI 上运行 Cypress(npx cypress run)。我使用了 Cypress Orb,但我最近对其进行了扩展以添加更多故障排除信息。我的设置非常复杂,需要旋转 5 个容器来提供测试环境。所以,我在 Circle CI 机器上运行它,而不是 docker。

问题:赛普拉斯测试我的 baseUrl 是否存在,但发现它不是,但我可以通过在 curl 语句之前单独证明它是存在的。我能想到的只是赛普拉斯没有使用配置的 baseUrl,但我不知道它是什么,因为它被屏蔽了,以及其他敏感信息。我尝试将-dev标志添加到 cypress 命令中,但信息仍然被屏蔽。

这是我的 config.yml 中“命令”的相关部分:

grep baseUrl cypress.json
echo -n "curl port 3091: "
curl -s -S -i localhost:3091 | grep -q 'HTTP/1.1 200 OK'
if [ $? -ne 0 ]; then
  echo "ran into an error"
  curl -i localhost:3091
else
  echo "OK"
fi
echo "cypress info:"
npx cypress info --dev
echo "run cypress"
set +e
npx cypress run --dev --browser chrome
if [ $? -ne 0 ]; then
  npx cypress run --browser chrome &> cypress-run.log
  echo "error, here is the cypress output:"
  cat cypress-run.log
  exit 1
fi

这是该代码的输出,在 Circle CI 上执行:

baseUrl:   "baseUrl": "http://localhost:3091",
curl port 3091: OK
cypress info:

Proxy Settings: none detected
Environment Variables:
CYPRESS_testPassword: ********************
CYPRESS_baseUrl: *********************
CYPRESS_CACHE_FOLDER: ~/.cache/Cypress
CYPRESS_testUsername: *******************************************
CYPRESS_RECORD_KEY: <redacted>

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

Cypress Version: 6.8.0
System Platform: linux (Ubuntu - 20.04)
System Memory: 33.7 GB free 11.3 GB
run cypress
error, here is the cypress output:
Cypress could not verify that this server is running:

  > *********************

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

Cypress failed to verify that your server is running.
Please start this server and then run Cypress again.
Exited with code exit status 1

有什么方法可以取消赛普拉斯的输出?我搜索了赛普拉斯文档并进行了网络搜索,但结果很短。

标签: cypresscircleci

解决方案


好的,灯泡打开了,所以我可以回答我自己的问题。

  1. 赛普拉斯没有掩盖输出,Circle CI 正在这样做。这是#2的线索。

  2. Circle CI 被设置(不是我)来定义 CYPRESS_baseUrl 环境变量。Cypress 使用它的值来覆盖 cypress.json 文件中的设置。而且,环境变量中的值不正确!

一旦我删除了环境变量,它就开始工作了。


推荐阅读