Hello: Need your help on a chai
assertion.
I have a JSON response as shown below. I want to assert that it contains "Lastname is mandatory" only.
I tried using this statement but the error i get is AssertionError: expected [ Array(2) ] to have a deep property '#text'
. Please help how to write this correctly.
using expect
chai.expect(data.response.error).to.have.deep.property('#text', 'Lastname is mandatory.');
using should
data.response.error.should.have.deep.property('#text', 'Lastname is mandatory.');
Response JSON
{
response: {
error: [
{
'@id': '1000',
'#text': 'Firstname is mandatory.'
},
{
'@id': '10001',
'#text': 'Lastname is mandatory.'
}
],
result:
{
status: '0'
}
}
}