Mocha, Chai: Assert that Object is included in an Array of Objects

Here is an alternative and non order dependent approach for collections:

array

expect([1, 2, 3]).to.include.members([3, 2, 1])

You can also use this with a deep flag for comparison of objects:

array of objects

expect([{ id: 1 }]).to.deep.include.members([{ id: 1 }]);

object

expect({foo: 'bar', width: 190, height: 90}).to.include({ height: 90, width: 190 })

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)