【发布时间】:2021-06-17 09:36:59
【问题描述】:
我正在努力应对以下情况。我通过网页创建一个新用户,并将其保存到 json 文件中。但是我在 cypress 中的测试无法在文件中搜索“深度”。
这就是我的 json 文件的样子:
{
"customers" : [ {
"customerId" : "123456",
...
} ],
"error" : ""
}
这就是我在测试中加载这个 json 文件的方式:
beforeEach('Load fixture', function () {
cy.fixture('registerNewCustomers').its('customers').as('testdata');
});
...
cy.get('@testdata').then((testdata) => {
cy.get('#inputLoginID').type(testdata.customerId);
我的测试无法读取嵌套的“customerId”,但如果我将其移至“客户”级别,我的测试将找到它及其值。
{
"customers" : [ {
...
...
} ],
"error" : "",
"customerId" : "123456",
}
【问题讨论】: