Skip to content

toHaveDisplayValue custom matcher #221

@cloud-walker

Description

@cloud-walker

I'm testing a labeled select that I query with getByLabelText, I then want to assert that the select has a default display name, but I can't find a jest matcher for that, here a snippet example:

const select = screen.getByLabelText('Fruits')
expect(select).toBeVisible()
expect(select).toHaveDisplayValue('Select a fruit')

For now I think I should write a custom matcher myself, or a more complicated query 🤔

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