Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to add non-existing snapshots instead of raising an error #843

Open
claytonkreisel opened this issue Dec 19, 2023 · 2 comments
Open
Labels
feature request New feature or request

Comments

@claytonkreisel
Copy link

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

The issue is that I have to run --snapshot-update in order to initiate a new assertion in a test. This is mostly an annoyance when testing with PyCharm using the IDE testing tools.

Describe the solution you'd like

I would prefer that there is an option that I can set by default that will not update any existing snapshots, but will add any newly created snapshots.

Describe alternatives you've considered

A flag called create-non-existing-snapshots as an option that can be set. This could then be configured in CLI or an IDE.

Additional context

None

@tducret
Copy link

tducret commented Feb 8, 2024

Hi there!
I have the same request 😄

On top of that, I think it would be a great way to onboard former snapshottest users, as creating non-existing snapshots without passing the --snapshot-update option is the default behavior in snapshottest.

Is there any chance we could implement that?

@noahnu noahnu added this to Syrupy Aug 23, 2024
@noahnu
Copy link
Collaborator

noahnu commented Nov 23, 2024

I'm open to this idea as opt-in, perhaps a flag --snapshot-update-new-only or something like that.

I will say this was an intentional design decision when initially creating syrupy. This is personal opinion however I believe snapshottest's approach of auto-creating the snapshots when missing is problematic. Imagine if you've written a number of new test cases and forget to create the relevant snapshots. If you push up your changes to your version control system and your CI system runs the test suite, with auto-create functionality, the tests will pass. This gives a false sense of confidence in the test suite. For all you know, the generated snapshot could be different every CI run.

Syrupy's stance is that a missing snapshot is no different from a non-matching snapshot. Syrupy has no way of knowing that you've just written a new test case and so we expect a snapshot not to exist, vs. a test case has been renamed disconnecting it from the snapshot file, or the dev forgot to commit the snapshot artifacts to git when pushing up their branch for CI to run.

@noahnu noahnu added the feature request New feature or request label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
Status: No status
Development

No branches or pull requests

3 participants