cupaloy icon indicating copy to clipboard operation
cupaloy copied to clipboard

Feature request: support Property Matchers like Jest

Open cdignam-segment opened this issue 2 years ago • 1 comments

Jest has a great feature for matching specific types for fields: https://jestjs.io/docs/snapshot-testing#property-matchers

It would be great if this library also support this.

cdignam-segment avatar Jan 24 '22 18:01 cdignam-segment

Hey 👋🏻

Unfortunately, this sounds a pretty tricky feature to implement in this library. Whereas jest has you specify your snapshots in code, cupaloy does the snapshotting for you and saves them to disk.

The closest library I know of that might help is https://github.com/sebdah/goldie which lets you have Go templates as your snapshots and interpolate values into them at test-time: https://github.com/sebdah/goldie#assertions-using-templates

In contast, cupaloy is very simple and so requires that the datastructure you pass in already has any non-deterministic/non-repeatable data (like timestamps, etc.) mocked out with static values

bradleyjkemp avatar Jan 25 '22 14:01 bradleyjkemp