Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How do I make sure that the rendered component has only 1 accessible element? #1807

Unanswered
itsramiel asked this question in Q&A
Discussion options

Hi,

I am building a component, and from a user-facing perspective this components serves as a whole unit, so I want to assert exactly that. That when this component is read by screen readers it is read as 1 unit.

As a result I want to write a test to make sure that the rendered component has only 1 accessible element.

One idea I had is to get all accessible elements and make sure that the count is 1, but I am not sure how to do that. Can someone help me?

You must be logged in to vote

Replies: 1 comment 3 replies

Comment options

As far as I can think, there is no way to achieve that now

You must be logged in to vote
3 replies
Comment options

What do you think of this

expect(screen.queryAllByRole(/.+/)).toHaveLength(1);
Comment options

Hmmm, there is a chance it might actually work. You would need to do some testing

Comment options

Hmmm, there is a chance it might actually work. You would need to do some testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /