在 cypress.json 文件中我有以下代码
{
"baseUrl": "test",
"ignoreTestFiles": [],
"viewportHeight": 768,
"viewportWidth": 1024,
"video": false,
"env": { "email": "test@email.com", "password": "password" }
}
Run Code Online (Sandbox Code Playgroud)
当我尝试通过调用 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");
});
Run Code Online (Sandbox Code Playgroud)