Skip to content

Commit

Permalink
Capture emitted output as a test (#2756)
Browse files Browse the repository at this point in the history
* capture emitted output in tests

* also confirm invisible(), why not
  • Loading branch information
MichaelChirico authored Feb 16, 2025
1 parent d85ec68 commit a0233d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/test-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test_that("print.lints works", {

tmp <- withr::local_tempfile()
stopifnot(file.create(tmp))
expect_invisible(print(lint(tmp)))
expect_message(expect_invisible(print(lint(tmp))), "No lints found")
})

test_that("split.lint works as intended", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-rstudio_markers.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@ test_that("rstudio_source_markers apply to print within rstudio", {
expect_output(print(l), "matched", fixed = TRUE)

l <- lint(empty, seq_linter())
expect_output(print(l), "matched", fixed = TRUE)
expect_message(expect_output(print(l), "matched", fixed = TRUE), "No lints found")
})

0 comments on commit a0233d2

Please sign in to comment.