l2beat / earl

☕ Ergonomic, modern and type-safe assertion library for TypeScript
https://earl.fun/
MIT License
257 stars 19 forks source link

expect.toInclude with expect.subset() does not generate helpful error texts #284

Open dhardtke opened 1 year ago

dhardtke commented 1 year ago

(Follow-up to #283 but an issue that can be tackled separately)

Given:

{ _id: 42, foo: 'bar' },
  { _id: 43, foo: 'baz' },
  { _id: 44, lorem: 'ipsum' }
];
expect(items).toInclude([
  expect.subset({ x: 'y' }),
])

If toInclude fails the generated error message is not that helpful:

Uncaught The value [3 entries] does not include [expect.?], but it was expected to.
    at expect().toInclude

It would be great if we could see or opt-in to see the full object or maybe parts of the object that do not include what was expected?