I am trying to validate two json file and if the file data is valid then log it as "success", if it is invalid log it as "fails". But my test case tend to show fail all the time even the value present in the file is correct. I checked the values in the file by introducing logs in each function.
I tried the above stuff but i receive "fail" all the time If there could be a solution i would be happy, i am not sure what is wrong 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"
}`