Testing for an object key in an array of objects using mocha and chai

Viewed 1529

If I have an object that is an array of objects

{ "places": [ {city: "Pittsburgh", state: "PA"} ] }

how do I test to see if the array at index 0 (places[0]) has an object with a key "city"? I tried this but it didn't work

expect( {"places": [ {"city": "Pittsburgh", "state": "PA"} ] } ).to.nested.include({"places[0]" : "city"});
1 Answers
Related