chai-subset or chai-fuzzy can also do what you are looking for.
Chai-subset should work like this:
expect([ { C1: 'xxx', C0: 'this causes it not to match.' } ]).to.containSubset([{C1: 'xxx'}]);
Personally, if I do not want to include another plugin, I will use the property or matching keys , which includes Chai:
([ { C1: 'xxx', C0: 'this causes it not to match.' } ]).forEach(obj => { expect(obj).to.have.key('C1'); // or... expect(obj).to.have.property('C1', 'xxx'); });
thom_nic
source share