Skip to content

Regarding lifecycle of expect_snapshot_warning() #2182

@njtierney

Description

@njtierney

I note in

https://testthat.r-lib.org/reference/expect_snapshot_output.html

That expect_snapshot_warning() and co are in a questioning lifecycle.

I personally find it really useful to use expect_snapshot_warning() as a way to capture the entire warning message, and not the output. Is there a recommended way that you'd recommend testing this otherwise? Currently it seems my approach is:

expect_snapshot(
  tmp <- function_to_warn(x)
)

I understand I can capture an error message with:

expect_snapshot(
  error = TRUE,
  function_to_warn(x)
)

But I want to capture the warning. Is there a recommended approach for the future that you'd recommend users use to capture things like warnings?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions