bezzoon
bezzoon

Reputation: 2019

How to make assertions on nested fields with newman

response

{
   user: {
          id: 1000
    }

I can make an assertion on the user key

pm.expect(response).to.have.key("user")

How do I make an assertion that id is there?

I tried this and it doesn't work:

pm.expect(response.user).to.have.key("user")

Upvotes: 0

Views: 108

Answers (1)

bezzoon
bezzoon

Reputation: 2019

Use this:

pm.expect(response.user).to.have.property('id')

Upvotes: 0

Related Questions