Reputation: 464
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"});
Upvotes: 3
Views: 1844
Reputation: 10356
You should use to.have.nested.property
instead of to.nested.include
:
var obj = {"places": [ {"city": "Pittsburgh", "state": "PA"} ] };
expect(obj).to.have.nested.property("places[0].city");
Upvotes: 6