tests/testthat/test-images.R

context("images")

test_that("capturePlot works with device functions with various signatures", {

  # If these run without throwing, that's success

  capturePlot(plot(cars), device = grDevices::png)

  capturePlot(plot(cars), device = function(filename, width, height) {
    grDevices::png(filename = filename, width = width, height = height)
  })

  capturePlot(plot(cars), device = function(filename, ...) {
    grDevices::png(filename = filename, ...)
  })

  # Ensure blank plot works
  plotTag({}, alt = "", device = png)

  # So testthat knows we didn't skip testing
  expect_true(TRUE)
})

Try the htmltools package in your browser

Any scripts or data that you put into this service are public.

htmltools documentation built on Nov. 3, 2023, 5:07 p.m.