【发布时间】:2021-10-27 19:09:50
【问题描述】:
如何将环境名称传递给赛普拉斯测试以加载一组环境变量?赛普拉斯页面仍然神秘,没有回答这个问题:https://docs.cypress.io/guides/guides/environment-variables#Option-2-cypress-env-json
此外,他们的示例以迫使我编写 shell 脚本来处理切换变量的方式做到这一点:https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/server-communication__env-variables。没有办法硬编码环境名称对我有用:https://github.com/cypress-io/cypress-example-recipes/blob/2e5fb3da420f544637ff77d81ff7261f5d2164e8/examples/server-communication__env-variables/cypress/integration/spec.js#L5
所以,我创建了一个名为 cypress.playground.json 的文件,但我不知道如何告诉赛普拉斯加载它。
{
"baseUrl": "https://my-url.hostname/ui/",
"defaultCommandTimeout": 10000,
"video" : true
}
并且,从命令行运行时。这是我“猜测”如何传递 env 值:
✘-1 ~/Documents/GitHub/me [Branch-Name|✔]
16:35 $ cypress run --headed --browser chrome --env playground
Cypress encountered an error while parsing the argument env
You passed: playground
The error was: Cannot read property 'split' of undefined
✘-1 ~/Documents/GitHub/me [Branch-Name|✔]
16:35 $ cypress run --headed --browser chrome --config playground
Cypress encountered an error while parsing the argument config
You passed: playground
The error was: Cannot read property 'split' of undefined
我的意图是在运行测试之前覆盖默认值 baseUrl。
【问题讨论】:
标签: cypress