Skip to content

Property "hidden" is unintuitive #1361

@alxbradley

Description

@alxbradley

I'm fairly new to testing-library and I spent nearly an hour trying to figure out why my dialog isn't found by findByRole.

I can SEE my dialog in the DOM, but there's no error message like, "Hey, I see the dialog in the DOM, but it's hidden, add {hidden: true} to your query".

Sure, this might be a skill issue. I forgot that dialogs are hidden from the accessibility tree. But I can SEE the dialog, so it's not hidden right?

Describe the feature you'd like:

I can think of a few options,

  1. Change the name from 'hidden' to something that captures the meaning better. Maybe ariaHidden
  2. Show helpful errors
    Maybe when you print the DOM to screen show a label next to it such as:
    <dialog (hidden=true)
        aria-label=".."
        role="dialog"
     >
  1. Add a hint in the error log Unable to find role="dialog". Try adding "{hidden: true}" to your 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