bahmutov / snap-shot-core

Save / load named snapshots, useful for tests
14 stars 9 forks source link

[Feature Request] add property matchers #194

Open andykais opened 5 years ago

andykais commented 5 years ago

It would be awesome to see property matchers like those in jest's snapshot testing. In short, they allow you to specify certain fields to ignore in JSON snapshots

e.g. (using jest's snapshots)

const obj = {
  id: dynamic(),
  foo: 'bar',
  other: 'value',
  val: 1,
};
expect(obj).toMatchSnapshot({
  id: expect.any(String),
});

linked here is jest's documentation of this feature: https://jestjs.io/docs/en/snapshot-testing#property-matchers

kuceb commented 5 years ago

This could be done if the compare function also can change the what, so you could just bring your own compare function that implements property matchers