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 disable snapshot diffing #581

Open
RobertCraigie opened this issue Jan 19, 2022 · 5 comments
Open

Add option to disable snapshot diffing #581

RobertCraigie opened this issue Jan 19, 2022 · 5 comments
Labels
feature request New feature or request good first issue Good for newcomers

Comments

@RobertCraigie
Copy link

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

I have multiple massive (~10k lines) snapshots and if any of them fail it takes a considerable amount of time to produce the diff. I also don't need to know what the difference is in this case.

An example snapshot can be found here: https://github.com/RobertCraigie/prisma-client-py/blob/main/tests/test_generation/exhaustive/__snapshots__/test_exhaustive/test_async%5Bactions.py%5D.raw

Describe the solution you'd like

Add a new config / cli option to disable diff creation and instead just show an error that the snapshots differ.

Describe alternatives you've considered

None that I can think of.

Additional context

This was discovered from this CI run: https://github.com/RobertCraigie/prisma-client-py/runs/4859619412?check_suite_focus=true which I cancelled after 14 minutes (it usually takes at most 3 minutes to complete).

@noahnu
Copy link
Collaborator

noahnu commented Jan 20, 2022

Interesting. At first I thought this was a duplicate of #577, but your case has short line length, just a larger number of lines.

An option to disable the diff makes sense to me though I also wonder if we can achieve a diff in a reasonable amount of time. Or have some heuristic to fallback to a different diff format/system for large snapshots.

@RobertCraigie
Copy link
Author

I also wonder if we can achieve a diff in a reasonable amount of time.

I think that would be an incredible feat! I let another workflow run its course and it took 1 hour and 30 minutes to produce 4 snapshot diffs: https://github.com/RobertCraigie/prisma-client-py/runs/4886243053?check_suite_focus=true

@noahnu noahnu added the feature request New feature or request label Jan 21, 2022
@BasitAli
Copy link

Have a similar problem, I have pytest-timeout and the tests are timing out while preparing the diff. This may be similar to #625 in a way, but at the moment, I'm also looking for just a way to disable diff if the snapshot doesn't match.

@BasitAli
Copy link

Temporary resolved it using a custom snapshot extension,

class NoDiffSnapshotExtension(SingleFileSnapshotExtension):
    def diff_snapshots(self, serialized_data, snapshot_data):
        return "diff-is-disabled"

    def diff_lines(self, serialized_data, snapshot_data):
        return ["diff", "is", "disabled"]

@RobertCraigie
Copy link
Author

Thank you so much @BasitAli! That is a very nice solution :)

RobertCraigie added a commit to RobertCraigie/prisma-client-py that referenced this issue Nov 19, 2022
RobertCraigie added a commit to RobertCraigie/prisma-client-py that referenced this issue Nov 19, 2022
@noahnu noahnu added the good first issue Good for newcomers label Aug 28, 2023
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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants