Skip to content

Commit d65933d

Browse files
authored
Use cat() to avoid cli wrapping (#1744)
Fixes #1726
1 parent 1764ab0 commit d65933d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# testthat (development version)
22

3+
* `expect_snapshot()` no longer elides new lines when run interactively (#1726).
4+
35
* Experimental new `with_mocked_bindings()` and `local_mocked_bindings()`
46
(#1739).
57

R/snapshot.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ snapshot_accept_hint <- function(variant, file, reset_output = TRUE) {
426426
snapshot_not_available <- function(message) {
427427
cli::cli_inform(c(
428428
"{.strong Can't compare snapshot to reference when testing interactively.}",
429-
i = "Run {.run devtools::test()} or {.code testthat::test_file()} to see changes.",
430-
i = message
429+
i = "Run {.run devtools::test()} or {.code testthat::test_file()} to see changes."
431430
))
431+
cat(message, "\n", sep = "")
432432
}
433433

434434
local_snapshot_dir <- function(snap_names, .env = parent.frame()) {

tests/testthat/test-snapshot-reporter.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ test_that("basic workflow", {
1313
snapper <- local_snapshotter(path)
1414
snapper$start_file("snapshot-2")
1515
# output if not active (because test not set here)
16-
expect_message(expect_snapshot_output("x"), "Can't compare")
16+
expect_snapshot_output("x") %>%
17+
expect_message("Can't compare") %>%
18+
expect_output("Current value:\n[1] \"x\"", fixed = TRUE)
1719

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

0 commit comments

Comments
 (0)