Skip to content

Commit a9ce626

Browse files
committed
Don't use random port
1 parent 9ebc3da commit a9ce626

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/testthat/test-preview.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ test_that("quarto_preview can change port", {
2828
withr::local_dir(tmp_dir)
2929
xfun::write_utf8(c("---", "title: Test", "---", "", "# Hello"), "test.qmd")
3030

31+
known_port <- find_port()
3132
expect_no_error({
3233
preview_url <- withr::with_dir(tmp_dir, {
33-
quarto_preview("test.qmd", port = 8888, browse = FALSE, quiet = TRUE)
34+
quarto_preview(
35+
"test.qmd",
36+
port = known_port,
37+
browse = FALSE,
38+
quiet = TRUE
39+
)
3440
})
3541
})
3642

@@ -40,5 +46,5 @@ test_that("quarto_preview can change port", {
4046
skip_if(!exists("preview_url", inherits = FALSE))
4147
skip_if(!is.character(preview_url))
4248
expect_true(grepl("^https?://", preview_url))
43-
expect_true(grepl(":8888", preview_url))
49+
expect_true(grepl(sprintf(":%s", known_port), preview_url))
4450
})

0 commit comments

Comments
 (0)