tophat / syrupy

:pancakes: The sweeter pytest snapshot plugin
https://tophat.github.io/syrupy
Apache License 2.0
501 stars 33 forks source link

Option to define snapshot directory name #810

Open silverwind opened 10 months ago

silverwind commented 10 months ago

Is your feature request related to a problem? Please describe.

I prefer to name my snapshot directory snapshots instead of __snapshots__. I feel the underscores are unnecessary noise.

Describe the solution you'd like

A CLI option --snapshot-dirname <name>

Describe alternatives you've considered

None

Additional context

In JS, I use vitest's resolveSnapshotPath option for the same, it is a bite more flexible as it allows full customization of the path, but I guess I would be happy with a static option just to define the directory name.

noahnu commented 9 months ago

It's possible to implement a custom dirname via a custom snapshot extension. I agree though that first-party support would be welcome and preferred.

We reference the snapshot name in a couple places, mostly coming from the base extension abstract class. We don't currently expose syrupy options to the extension itself though. This would be far easier after https://github.com/tophat/syrupy/pull/816 is implemented. We might be able to come up with a bit more of a hacky solution or workaround until PR 816 and subsequent related changes are merged though.