Skip to content

[Feature]: Assertions custom message function support #2468

Open
@infime

Description

@infime

🚀 Feature Request

expect can take a custom message to display if the assertion fails. Would like the ability to optionally provide a function to construct and return the message.

Example

async def mesg(loc):
  # create a useful error message based on the locator.
  
  return fancy_message

await expect(loc, message=mesg)

Motivation

In cases where additional context is useful to explain the assertion failure, being able to construct this dynamically based on the locator in question would be useful.

Constructing the failure message beforehand isn't feasible since the locators may have changed while waiting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions