0 cypress
我的想法是我想使用操作,每个操作都有一个名称和一个固定文件,
每个路径都有一个包含数据的文件。
我有一个命令,只需调用操作名称即可获取固定文件,这里的主要问题是固定装置的 json 文件中的代码是否正确:
{
"stremeadConfig": "./alerts-escalation-param.stremead.json",
"screenIds": [],
"institutionInputId": "bank_code",
"screenLabels": {
"searchLabels": "./alerts-escalation-param.search-labels.json",
"detailsLabels": "./alerts-escalation-param.details-labels.json"
},
"search": "./alerts-escalation-param.select.json",
"searchCriteriaFields": [],
"requiredFieldsOnSearchScreen": [],
"requiredFieldsOnDetailsScreen": [],
"operationsDefaultExpectedValues": {
"numberOfColumnsOnEmptyRow": 1,
"numberOfRecordsAfterDelete": 0
},
"existingDataToDelete": "./alerts-escalation-param.existing.json",
"operations": [
"./alerts-escalation-param.select.json",
"./alerts-escalation-param.create.json",
".alerts-escalation-param.update.json",
"./alerts-escalation-param.duplicate.json",
"./alerts-escalation-param.delete.json"
]
}
Run Code Online (Sandbox Code Playgroud)
这是一个自定义命令,可以根据指定的操作加载夹具。
Cypress.Commands.add('fixtureForOperation', (operation) => {
return cy.fixture('my-fixtures.json').then(fixtureMain => {
const fixturePath = fixtureMain.operations.find(path => {
return path.contains(operation)
})
if (!fixturePath) {
throw new Error('Operation not found in fixtures')
})
return cy.fixture(fixturePath)
})
})
Run Code Online (Sandbox Code Playgroud)
测试
cy.fixtureForOperation('duplicate').then(data => {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
221 次 |
| 最近记录: |