Skip to content

New linter to enforce specific regexp error message in expect_error #2870

@nicklamiller

Description

@nicklamiller

A linter that enforces calls to testthat::expect_error have a non-NULL regexp argument would be helpful to ensure tests that expect failure only fail with the specified error message and not for some unanticipated reason. This is analogous to pytest-raises-too-broad (PT011) in ruff.

This linter (or maybe separate linters) could naturally enforce a specific regexp for other testthat functions that have a regexp argument: expect_error, expect_warning, expect_message, and expect_condition.

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