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 transform support to expect_snapshot_file() #1474

Closed
jennybc opened this issue Oct 7, 2021 · 1 comment · Fixed by #1530
Closed

Add transform support to expect_snapshot_file() #1474

jennybc opened this issue Oct 7, 2021 · 1 comment · Fixed by #1530
Labels
feature a feature request or enhancement snapshot 📷
Milestone

Comments

@jennybc
Copy link
Member

jennybc commented Oct 7, 2021

I just did something janky with expect_snapshot(writeLines(read_utf8(path)), transform = scrub_testpkg) when what I really wanted was expect_snapshot_file(path, transform = scrub_testpkg).

r-lib/usethis@e9a4bec

@hadley hadley modified the milestone: v3.1.1 Nov 24, 2021
@hadley hadley added feature a feature request or enhancement snapshot 📷 labels Dec 20, 2021
@hadley hadley added this to the v3.1.2 milestone Dec 20, 2021
@hadley
Copy link
Member

hadley commented Jan 5, 2022

The fiddly bit is that the defaults for expect_file_snapshot() imply that the files are binary (not text), so it would be a weird if transform was parameterised in the same way as expect_snapshot() (i.e. transforming a character vector). Maybe I can make compare a bit smarter so it can default to NULL and then guess based on the file extension.

hadley added a commit that referenced this issue Jan 5, 2022
And tweak `compare` default so we don't imply a byte-by-byte comparison but  a line-by-line transformation.

Fixes #1474
hadley added a commit that referenced this issue Jan 5, 2022
And tweak `compare` default so we don't imply a byte-by-byte comparison but  a line-by-line transformation.

Fixes #1474
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement snapshot 📷
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants