[英]Cypress environment variable undefined
在 cypress.json 文件中,我有以下代码
{
"baseUrl": "test",
"ignoreTestFiles": [],
"viewportHeight": 768,
"viewportWidth": 1024,
"video": false,
"env": { "email": "test@email.com", "password": "password" }
}
当我试图通过调用 Cypress.env('password') 来访问它时,它在打印时在控制台日志中显示未定义,这是什么问题。
const password: string = Cypress.env('password')
describe("Login to the application", () => {
beforeEach(() => {
cy.visit("/");
});
it.only("user should login successfully", () => {
console.log(Cypress.env('email')). --- undefined
loginPage.login(email, password);
cy.url().should("include", "/wallet");
});
我不知道或不检查 cypress.json 文件位置的错误,将其移动到顶部 cypress 文件夹并正确显示值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.