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

Enforce that snapshot files should be unique #1592

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

schloerke
Copy link
Contributor

@schloerke schloerke commented Mar 21, 2022

It seems odd that two different tests can save to the same snapshot file without error. This PR enforces that once a snapshot file has had an expectation, it can not have another expectation.

I tried doing this in {shinytest2}, but it felt like a giant hack and should be pushed upstream to {testthat}.


Implementation details:

We can not use SnapshotReporter$snap_file_seen as it is encouraged to use this field via announce_snapshot_file(file) to avoid files being deleted.

However, if we record what has been saved, then no saved file should be duplicated. Once a new test file starts, $snap_file_saved should be reset


  • News entry

Can not use `SnapshotReporter$snap_file_seen` as it is encouraged to use this field via `announce_snapshot_file(file)` to avoid files being deleted.

However, if we record what has been saved, then no saved file should be duplicated. Once a new test file starts, `$snap_file_saved` should be reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant