snapshot-diff icon indicating copy to clipboard operation
snapshot-diff copied to clipboard

Support for inline snapshots

Open mattalxndr opened this issue 3 years ago • 1 comments

Would be nice to have inline snapshots for this library.

mattalxndr avatar Feb 07 '22 11:02 mattalxndr

@mattalexx (As a "workaround") You can do inline snapshots with the snapshotDiff and toMatchInlineSnapshot function.

For example, the following would generate an inline snapshot:

test('snapshot difference between 2 React components state', () => {
  expect(
    snapshotDiff(<Component test="say" />, <Component test="my name" />)
  ).toMatchInlineSnapshot();
});

I think it makes sense to provide a custom matcher though, since it's a cleaner API. This does not seem too hard -- I can submit a pull request for it. Hopefully this project is still being maintained and someone can release a new version though? cc: @thymikee

domsli avatar Mar 13 '22 06:03 domsli