Skip to content

snapshot_review() is not finding any files to reviewΒ #1545

@schloerke

Description

@schloerke

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 update

Created on 2022-01-07 by the reprex package (v2.0.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorsnapshot πŸ“·

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions