小编Art*_*rov的帖子

赛普拉斯环境变量未定义

在 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)

javascript automation node.js cypress

6
推荐指数
1
解决办法
5981
查看次数

标签 统计

automation ×1

cypress ×1

javascript ×1

node.js ×1