最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

赛普拉斯环境变量未定义

网站源码admin34浏览0评论

赛普拉斯环境变量未定义

赛普拉斯环境变量未定义

在 cypress.json 文件中,我有以下代码

{
  "baseUrl": "test",
  "ignoreTestFiles": [],
  "viewportHeight": 768,
  "viewportWidth": 1024,
  "video": false,

  "env": { "email": "[email protected]", "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 文件夹并且值正确显示。

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论