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.
chai-things
You can filter your array for elements having both keys set:
myArray.filter(a => a.email && a.phone)
and expect the count is 0:
expect(myArray.filter(a => a.email && a.phone)).to.be.an('array').that.is.empty;
1.4m articles
1.4m replys
5 comments
57.0k users