tests/testthat/test-warning.R

test_that("deprecation warning is displayed with backtrace", {
  skip_on_cran()
  skip_on_os("windows")

  init_warnings()

  local_options(
    rlang_trace_top_env = current_env(),
    rlang_trace_format_srcrefs = FALSE,
    crayon.enabled = FALSE
  )

  f <- function() g()
  g <- function() h()
  h <- function() deprecate_warn("1.0.0", "trace()")

  expect_deprecated(f())

  expect_snapshot({
    last_lifecycle_warnings()
  })
})
r-lib/lifecycle documentation built on Nov. 6, 2023, 11:33 p.m.