mercredi 3 février 2021

How can I check if array has an objects in Postman

I have a response the array with objects like this:

[
    {
        "id": 1,
        "name": "project one"
    },
    {
        "id": 2,
        "name": "project two"
    },
    {
        "id": 3,
        "name": "project three"
    }
]

Have can I check if my responsed array have an object { "id": 3, "name": "project three" } for example? I am trying to check by this way but it didn't work:

pm.test('The array have object', () => {
    pm.expect(jsonData).to.include(myObject)
})

Aucun commentaire:

Enregistrer un commentaire