gpt4 book ai didi

javascript - Cypress 环境变量未定义

转载 作者:行者123 更新时间:2023-12-05 04:29:48 24 4
gpt4 key购买 nike

在 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 文件夹中,值显示正确。

关于javascript - Cypress 环境变量未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72212781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com