Closed DavidArchibald closed 4 months ago
Hey 👋 thanks a lot for taking time creating this issue. Never thought about it, but having a quick look on Jest looks like this is supported. Need to spend some time though to think about the implementation and how it would work and will share my thoughts.
As for the api, I am thinking that config.Name("lorem").MatchSnapshot(...)
will introduce yet another way for configuring your snapshots. I know in some places it's not consintent but If I could go back in time I would do some things differently 😅 .
Until that, there is probably the workaround you suggested snaps.MatchSnapshot(t, good, bad)
and adding a separator
snaps.MatchSnapshot(t,"\nadding good snapshot\n====\n", good,"\nadding bad snapshot\n====\n", bad)
I think this doesn't give much of a value so will close it as won't fix. Happy to rediscuss it if people believe it's useful.
🚀 Feature Proposal
A way to substitute the simple incrementing number in snapshot files, e.g.
TestName - 1
,TestName - 2
, etc. with a proper name. I'd be willing to PR this.Motivation
The clarity of snapshots being named
TestName - 1
,TestName - 2
, and so on can be subpar in the case of a test doing something like this:I'm aware of the form
snaps.MatchSnapshot(t, good, bad)
where it'll only create one entry but that version doesn't even indicate where one value starts and the other one ends.Example
One or multiple of these APIs would be added:
As for how
config.Name("foo")
being used more than once would work I could go two ways:TestName - foo/1
andTestName - foo/2
and so on is generated.