Match partial objects in Chai assertions?

chai-subset or chai-fuzzy might also perform what you’re 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 don’t want to include another plugin I will use the property or keys matchers that chai includes:

([
  {
    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');
});

Leave a Comment

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