cypress - 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
有什么方法可以取消赛普拉斯的输出?我搜索了赛普拉斯文档并进行了网络搜索,但结果很短。
解决方案
好的,灯泡打开了,所以我可以回答我自己的问题。
赛普拉斯没有掩盖输出,Circle CI 正在这样做。这是#2的线索。
Circle CI 被设置(不是我)来定义 CYPRESS_baseUrl 环境变量。Cypress 使用它的值来覆盖 cypress.json 文件中的设置。而且,环境变量中的值不正确!
一旦我删除了环境变量,它就开始工作了。
推荐阅读
- ignite - 如何在没有自定义函数的 SQL 中使用 ID 生成器
- javascript - 如何在一天后调用Javascript倒计时并将一周添加到计时器中
- azure - 在 Azure 数据工厂副本中使用附加 blob 是否有任何解决方法?
- nested - 在 Mapbox 中显示嵌套 GeoJson 的属性
- meteor - 流星未运行显示节点光纤问题
- python - 使用递归制作单词序列
- php - 即使事件被触发,Laravel 监听器也不会被触发
- prolog - Prolog 几何三角规则
- c# - 检测登录 - SQLMembershipProvider
- cordova - 带有cordova插件的离子中BLE应用程序的最佳结构是什么