lundi 25 janvier 2021

Chai expect objects inside array to not include multiple properties

How to assert that all objects inside array do not include multiple properties. Example all of them should not include keys "email" and "phone".

const myArray = [
   {name: "John Doe", email: "john@gmail.com", phone: "9xxxxxxxxxx"},
   {name: "Jane Doe", email: "jane@gmail.com", phone: "9xxxxxxxxxx"},
   {name: "Johny Doe"}
]

// this seems to do what I want 
// but doesn't "something" check if any object passes the test?
expect(myArray).to.contain.something.that.does.not.include.any.keys("email", "phone")

Using chai-things.

Aucun commentaire:

Enregistrer un commentaire