skip to Main Content

I’m trying to verify TotalMessageUI_ObjectClicked contains a value other than NULL or 0

But I keep getting this error:

AssertionError: expected [ { payload: { data: [Object] } } ] to have property ‘TotalMessageUI_ObjectClicked’

What is the best way to verify TotalMessageUI_ObjectClicked contains a value not NULL

{"data":{"actor":{"account":{"nrql":{"results":[{"TotalMessageUI_ObjectClicked":6}]}}}}}

Tried writing this:

expect(response.body).have.property('TotalMessageUI_ObjectClicked').to.not.be.oneOf([null, "",0]) 

2

Answers


  1. You are not drilling down to the correct prop in your expected result.

    expect(response.body[0].payload.data.actor.account.nrql.results[0])
      .have.property('TotalMessageUI_ObjectClicked')
      .to.not.be.oneOf([null, "",0])
    
    Login or Signup to reply.
  2. The message

    AssertionError: expected [ { payload: { data: [Object] } } ] to have …

    is telling you that response.body (the object you supplied) is actually [{ payload: { data: [Object] } } ].

    So you can amend your test with that info, for example:

    expect(response.body[0].payload.data.actor.account.nrql.results[0].TotalMessageUI_ObjectClicked)
      .to.not.be.oneOf([null, 0])
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search