testing-library / testing-library/dom-testing-library

Allow queries to take optional filter function

Open
#684 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted needs discussion
Dominant language
JavaScript
Stars
3.3k
Forks
474
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names the getByText query, an optional filter function, and the possible isVisible export from jest-dom, but it names no implementation files or tests. Start by tracing the query API and existing visibility behavior; done should include an agreed filter design and resolve whether visibility helpers or queryVisibleBy* methods are part of the feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.