Skip to content

Allow queries to take optional filter function #684

Open
@lazytype

Description

@lazytype

Describe the feature you'd like:

A common pattern that I've been using is:

const element = getByText(...);
expect(element).toBeVisible();

However, it may be the case that there are invisible elements that match the first selector, leading to a thrown error since multiple elements were found. It would be much nicer to be able to write something like:

const element = getByText(..., {filter: isVisible}); // It would also be nice for jest-dom to export `isVisible`

Describe alternatives you've considered:

If theisVisible use-case is by far the most common, then it could be sufficient to export queryVisibleBy* methods directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededneeds discussionWe need to discuss this to come up with a good solution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions