Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// cy.its(...) yields the property value
// so if we want to validate the response object
// we need to get the XHR object again
// by now the object exists, thus we can use cy.get()
cy.get('@post').its('response').should(spok({
headers: {
'content-type': 'application/json; charset=utf-8',
'cache-control': 'no-cache',
},
body: {
title: 'example post',
body: spok.string,
userId: 1,
// we don't know the exact id the server assigns to the new post
// but it should be > 100
id: spok.gt(100),
},
}))
})
})