我正在try 验证两个JSON文件,如果文件数据有效,则将其记录为"成功",如果无效,则将其记录为"失败".但是我的测试用例总是显示失败,即使文件中的值是正确的.我通过在每个函数中引入日志(log)来判断文件中的值.
我try 了上面的方法,但总是收到"失败"的消息 如果有解决办法,我会很高兴,我不确定出了什么问题 output个
test.cy.js个
cy.get('.dataTable-custom').get('.w-40').eq(0).then((el) => {
cy.writeFile('request-number.json',
{
request_number: el.text()
})
})
cy.readFile('request-number.json').then((request) => {
expect(request).to.be.an('object')
cy.log(request)
cy.readFile('application-details.json').then((json) => {
expect(json).to.be.an('object')
cy.log(json)
if (request === json) {
cy.log("success")
}
else {
cy.log("fail")
}
})
})```
**request-number.json**
`{
"request_number": "ARS/0099/2023"
}`
**application-details.json**
`{
"request_number": "ARS/0099/2023"
}`