Skip to content

expect_message() could be more helpful if expected string is not matchedΒ #2319

@mcol

Description

@mcol

This got me stuck for a while:

expect_message(cli::cli_alert_warning("'args' contains only fixed elements"),
               "'args' contans only fixed elements")

# ! 'args' contains only fixed elements
# Error: Expected `cli::cli_alert_warning("'args' contains only fixed elements")` to throw a message.

Initially I thought that perhaps for cli_alert_warning() I should have used expect_output() or expect_warning(), but neither of those helped. Only after a lot of head-scratching I realised that there was a typo in my expectation.

I think the wording expected to throw a message is misleading when a message is actually being thrown. Ideally in such case, it should say something like:

  `actual`: ! 'args' contains only fixed elements
`expected`: ! 'args' contans only fixed elements

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