-
Notifications
You must be signed in to change notification settings - Fork 318
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
Wrong snapshot_accept()
suggestion if period in test file name
#1669
Labels
Comments
I ran into the same issue; here's a reprex: https://github.com/d-morrison/testthat.suffix.issue |
|
mcol
added a commit
to mcol/testthat
that referenced
this issue
Nov 17, 2024
mcol
added a commit
to mcol/testthat
that referenced
this issue
Nov 17, 2024
This changes slightly the logic for matching file names: - before if a file name was considered to be without extension, we would add the `.md` and then compare it with the actual file names in the `_snaps` directory. However, that would fail if the file contained dots, as they would be considered to be a file extension: for them no `.md` was added to their name, and therefore they would never match with the actual files in the `_snaps` directory, so no update could ever succeed - with this patch, we strip any `.md` or `.txt` extension from the file names received by `snapshot_manage()`, and compare those with the actual file names from the `_snaps` directory also without extension
mcol
added a commit
to mcol/testthat
that referenced
this issue
Dec 21, 2024
This changes slightly the logic for matching file names: - before if a file name was considered to be without extension, we would add the `.md` and then compare it with the actual file names in the `_snaps` directory. However, that would fail if the file contained dots, as they would be considered to be a file extension: for them no `.md` was added to their name, and therefore they would never match with the actual files in the `_snaps` directory, so no update could ever succeed - with this patch, we strip any `.md` or `.txt` extension from the file names received by `snapshot_manage()`, and compare those with the actual file names from the `_snaps` directory also without extension
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a test file called "test-data.frame.R" (notice there are 2 periods in full name)
When running tests with a new output I get the suggestion to run
snapshot_accept("data.frame")
When I run it however I get "No snapshots to update"
This is due to
testthat:::snapshot_meta
where we find :There "frame" is returned by
tools::file_ext()
so no suffix is added.A solution might be to have :
Another solution would be to manage to have the suggestion be
snapshot_accept("data.frame.md")
The text was updated successfully, but these errors were encountered: