Skip to content

Commit

Permalink
Use cat() to avoid cli wrapping
Browse files Browse the repository at this point in the history
Fixes #1726
  • Loading branch information
hadley committed Mar 1, 2023
1 parent 253c882 commit 9f4d38f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# testthat (development version)

* `expect_snapshot()` no longer elides new lines when run interactively (#1726).

* Experimental new `with_mocked_bindings()` and `local_mocked_bindings()`
(#1739).

Expand Down
4 changes: 2 additions & 2 deletions R/snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ snapshot_accept_hint <- function(variant, file, reset_output = TRUE) {
snapshot_not_available <- function(message) {
cli::cli_inform(c(
"{.strong Can't compare snapshot to reference when testing interactively.}",
i = "Run {.run devtools::test()} or {.code testthat::test_file()} to see changes.",
i = message
i = "Run {.run devtools::test()} or {.code testthat::test_file()} to see changes."
))
cat(message, "\n", sep = "")
}

local_snapshot_dir <- function(snap_names, .env = parent.frame()) {
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-snapshot-reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ test_that("basic workflow", {
snapper <- local_snapshotter(path)
snapper$start_file("snapshot-2")
# output if not active (because test not set here)
expect_message(expect_snapshot_output("x"), "Can't compare")
expect_snapshot_output("x") |>
expect_message("Can't compare") |>
expect_output("Current value:\n[1] \"x\"", fixed = TRUE)

# warns on first creation
snapper$start_file("snapshot-2", "test")
Expand Down

0 comments on commit 9f4d38f

Please sign in to comment.