Skip to content

Commit 9ebc3da

Browse files
committed
correctly protect against non existence
1 parent becaf85 commit 9ebc3da

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/testthat/test-preview.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ test_that("quarto_preview can change port", {
2929
xfun::write_utf8(c("---", "title: Test", "---", "", "# Hello"), "test.qmd")
3030

3131
expect_no_error({
32-
url <- withr::with_dir(tmp_dir, {
32+
preview_url <- withr::with_dir(tmp_dir, {
3333
quarto_preview("test.qmd", port = 8888, browse = FALSE, quiet = TRUE)
3434
})
3535
})
3636

3737
# Always clean up
3838
withr::defer(quarto_preview_stop())
3939

40-
if (exists("url")) {
41-
expect_true(grepl("^https?://", url))
42-
expect_true(grepl(":8888", url))
43-
}
40+
skip_if(!exists("preview_url", inherits = FALSE))
41+
skip_if(!is.character(preview_url))
42+
expect_true(grepl("^https?://", preview_url))
43+
expect_true(grepl(":8888", preview_url))
4444
})

0 commit comments

Comments
 (0)