【发布时间】:2020-06-22 12:54:05
【问题描述】:
我实际上使用了以下代码:
const userType = new Map([['Manager', '1'],['Developer', '2' ]])
for (const [key, value] of usertypes.entries())
{
it('log in', () =>
{
cy.login(key,value)
cy.xpath('path')
.click()
cy.xpath('path')
.should('have.value' , key)
})
}
要在其他测试中使用用户,我想在名为 users 的夹具中定义用户类型。我如何在这个测试中使用这个夹具? 我的 Json 文件看起来像:
[[
{"key": "Manager"},
{"value": "1"}
],
[
{"key": "Developer"},
{"value": "2" }
]]
我尝试在 beforeElse 中使用 cy.fixture,但我不需要在每个测试中都使用它,而且它不正确。 如何在我的测试中使用 users.json 的数据?
【问题讨论】:
标签: testing automated-tests cypress fixtures