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

Highlight non-breaking whitespace in getByRole failure message

Open
#1,314 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
3.3k
Forks
474
PR merge metrics
No merged PRs in 30d

Description

When using getByRole, represent non-breaking whitespace in failure output as  , so that it's easier to diagnose the distinguish between " " and  . This would be in the list below "here are the accessible roles" under the "name" output.

Motivation: Non-breaking whitespace is not collapsed into " " in the accname calculation. This is correct according to the ARIA spec, but is tricky to debug getByRole failures related to usage of non-breaking whitespace. See also #904

Alternatives considered

We considered a custom helper to automatically collapse whitespace, but that is harder to maintain and discover than having the behavior in the core library. Further, it does not actually represent end-user experience since the browser does not perform this collapsing automatically.

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

Start at the getByRole failure-message path and inspect the output under “here are the accessible roles,” especially the “name” field. Trace the existing failure output behavior, then add coverage showing that non-breaking whitespace is represented as \u0026nbsp; so spaces and non-breaking spaces are distinguishable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.