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

Collapse whitespace issue with  

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

Nobody has claimed this yet.

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

Description

Had an issue that stemmed from Cypress testing library but debugged into Dom testing library. The issue is this function.

When searching for text with a non breaking space such as "٤ UK£", the regex replaces the nbsp into a space. It's fairly obvious why the regex was used, but it's effectively converting all types of spaces into a "regular space". This then causes the text match to fail.

In my opinion, that's an unintentional side effect of collapseWhitespace.

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 with the linked function in src/matches.ts and inspect how collapseWhitespace handles the non-breaking space in the reported “٤ UK£” case. Done means matching text containing that space no longer fails as an unintended consequence of whitespace collapsing, with the behavior verified for this case.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.