diff --git a/tests/testthat/_snaps/ard_regression.md b/tests/testthat/_snaps/ard_regression.md index 28439ecd..19c55b98 100644 --- a/tests/testthat/_snaps/ard_regression.md +++ b/tests/testthat/_snaps/ard_regression.md @@ -68,15 +68,3 @@ 7 cyl.sd__(Intercept) cyl.sd__(Intercept) estimate 4.023 NULL NULL 8 Residual.sd__Observation Residual.sd__Observation estimate 3.149 NULL NULL -# ard_regression() warnings and errors return correctly - - Code - as.data.frame(ard_regression(mod)) - Output - variable context stat_name stat_label stat fmt_fn - 1 model_1 regression estimate Coefficient NULL NULL - warning - 1 Could not access test statistic of model parameters., Could not access test statistic of model parameters. - error - 1 Error: ! Unable to tidy `x`. - diff --git a/tests/testthat/test-ard_regression.R b/tests/testthat/test-ard_regression.R index 3ade0fec..d1d8ca46 100644 --- a/tests/testthat/test-ard_regression.R +++ b/tests/testthat/test-ard_regression.R @@ -44,14 +44,17 @@ test_that("ard_regression() does not produce `variable_level` column where not a }) test_that("ard_regression() warnings and errors return correctly", { + skip_if_not(is_pkg_installed(pkg = "parameters", reference_pkg = "cardx")) + # constructed a model where broom.helpers fails, + # fall back method uses parameters which returns different messaging. mod <- lm(AGE ~ ARM, data = cards::ADSL) mod$coefficients <- NULL + df <- mod |> + ard_regression() |> + as.data.frame() - expect_snapshot( - mod |> - ard_regression() |> - as.data.frame() - ) + expect_false(is_empty(df$error)) + expect_true(is_empty(df$stat[[1]])) }) test_that("ard_regression() follows ard structure", {