bezzoon
bezzoon

Reputation: 2019

How to make postman assertion on an array

"thing": [
            {
                "id": 1,
            }
         ]

How do I assert that thing is an array with an object that contains ID

I tried

expect(response.thing).to.deep.include('id');

But that doesn't work

Upvotes: 0

Views: 113

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

If you want to check:

  • the array contains String id

pm.expect(JSON.stringify(response.thing)).to.deep.include('id');

  • a nested object has key id

pm.expect(response.thing[0]).to.have.keys('id');

Upvotes: 1

Related Questions