Repository navigation
Closed
Labels
Milestone
Description
First half is with a variant. Second half is with no variant.
Both are failing to find any snaps to review.
Reprex:
library(testthat)
dir <- withr::local_tempdir()
#> Setting deferred event(s) on global environment.
#> * Will be run automatically when session ends
#> * Execute (and clear) with `withr::deferred_run()`.
#> * Clear (without executing) with `withr::deferred_clear()`.
snapper <- testthat:::local_snapshotter(dir)
snapper$start_file("test", "test")
test_that("test", {
local_edition(3)
expect_snapshot_value("a", variant = "barret")
})
#> ── Warning (<text>:8:3): test ──────────────────────────────────────────────────
#> Adding new snapshot to variant 'barret':
#> "a"
snapper$end_file()
dir(dir, recursive = TRUE)
#> [1] "barret/test.md"
snapper$start_file("test", "test")
test_that("test", {
local_edition(3)
expect_snapshot_value("b", variant = "barret")
})
#> ── Failure (<text>:16:3): test ─────────────────────────────────────────────────
#> Snapshot of "b" has changed:
#> `old`: "a"
#> `new`: "b"
#>
#> * Run `snapshot_accept('barret/test')` to accept the change
#> * Run `snapshot_review('barret/test')` to interactively review the change
#> Error:
#> ! Test failed
snapper$end_file()
dir(dir, recursive = TRUE)
#> [1] "barret/test.md" "barret/test.new.md"
## Should review the "barret" snaps, but currently does not
snapshot_review("barret/test")
#> No snapshots to update
snapshot_review("barret/test", path = dir)
#> No snapshots to update
snapper$start_file("test", "test")
test_that("test", {
local_edition(3)
expect_snapshot_value("a", variant = NULL)
})
#> ── Warning (<text>:33:3): test ─────────────────────────────────────────────────
#> Adding new snapshot:
#> "a"
snapper$end_file()
dir(dir, recursive = TRUE)
#> [1] "barret/test.md" "barret/test.new.md" "test.md"
snapper$start_file("test", "test")
test_that("test", {
local_edition(3)
expect_snapshot_value("b", variant = NULL)
})
#> ── Failure (<text>:41:3): test ─────────────────────────────────────────────────
#> Snapshot of "b" has changed:
#> `old`: "a"
#> `new`: "b"
#>
#> * Run `snapshot_accept('test')` to accept the change
#> * Run `snapshot_review('test')` to interactively review the change
#> Error:
#> ! Test failed
snapper$end_file()
dir(dir, recursive = TRUE)
#> [1] "barret/test.md" "barret/test.new.md" "test.md"
#> [4] "test.new.md"
## Should also review the non-variant "test" snaps, but currently does not
snapshot_review("test")
#> No snapshots to update
snapshot_review("test", path = dir)
#> No snapshots to updateCreated on 2022-01-07 by the reprex package (v2.0.0)
Activity
hadley commentedon Jan 8, 2022
Reprex closer to what I'll test
hadley commentedon Jan 8, 2022
Hmmm at least part of the problem is that
snapshot_meta()always adds_snapsto the path, so this reprex isn't reflecting what you should see interactively. I'll fix that first.hadley commentedon Jan 8, 2022
Even more minimal reprex:
Created on 2022-01-07 by the reprex package (v2.0.1)
hadley commentedon Jan 8, 2022
Are you seeing this in real life?
schloerke commentedon Jan 8, 2022
Yes.
After updating to the latest from
mainthis afternoon, I could not review any snapshots withinshinytest2development (with or without variants).hadley commentedon Jan 8, 2022
With
expect_snapshot()orexpect_snapshot_file()?hadley commentedon Jan 8, 2022
Oooh, does
snapshot_review()work? Is it justsnapshot_review("specific-file")that doesn't?hadley commentedon Jan 8, 2022
The root problem is that
snapshot_accept("foo")might mean accept_snaps/foo.new.mdor_snaps/foo/*.new*schloerke commentedon Jan 8, 2022
From my terminal... (which is not a reprex, 😜 )
This shows that using
snapshot_review(files=)does not work.Yes! Skipping the
filesargument lets the code work.Better handling for file snapshots
Better handling of snapshot selection (#1546)
mrcaseb commentedon Feb 19, 2026
@hadley I found this issue and thought I might add this here first before opening a new issue.
I have slightly modified the example above to describe my issue. I hope this is right.
Here's what I see in my package development:
When passing a
varianttoexpect_snapshot()orexpect_snapshot_value()the printedsnapshot_hintprints incorrect files. It prints the name of the test file and misses the variant directory.I tried to create a reprex here. I hope this helps. Please let me know whether you want me to open a new issue.
Created on 2026-02-19 with reprex v2.1.1
Session info
hadley commentedon Feb 20, 2026
@mrcaseb please file a new issue.