小编Cos*_*Cos的帖子

问:Cypress 装置 - 无法读取未定义的属性

我正在尝试使用固定装置来保存不同测试的数据。这是代码的示例。当进行第二次测试时,我收到“无法读取未定义的属性‘电子邮件’”。

有什么想法以及如何解决这个问题吗?我对此很陌生,并且遵循了一个课程,他们说在“之前”使用固定装置的全部目的是让所有东西都可以访问数据。这是错误的吗?

谢谢

describe('Example', function() {
  before(function() {
    cy.fixture('dataFile').then(function(dataJson) {
      this.dataJson = dataJson;
    });
  });

  it('name', function() {
    cy.log(this.dataJson.email);
  });
  it('name2', function() {
    cy.log(this.dataJson.email);
  });
});
Run Code Online (Sandbox Code Playgroud)

cypress

5
推荐指数
2
解决办法
8925
查看次数

标签 统计

cypress ×1