-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
white space normalizing for text() function on mounted component ( appeared as /xa0) #1349
Comments
This isn't actually to "solve" this problem, the replacement is meant to simulate browser behavior of collapsing multiple whitespaces into one. In fact, that |
I did some digging and I'm not quite sure where the fix should go; linking to facebook/react#480 (comment) for posterity. |
I see your point. My original issue was regarding I am expecting text() function to act like text() function of other projects that scrape text from HTML and not like the browsers are rendering. Anyway the regex is far off from the link you shared |
Closed in #1350. |
I also saw something similar with shallow:
|
whoops, #1349 (comment) was meant to close this. @nelsonchen90 can you file a new issue for that? |
For now this works expect(container.find(`.${styles.foo}`).text()).toEqual('\u00a0'); Basically nbsps translate to this unix code |
It is probably too late but just in case I came across this problem when unit testing and found that I needed to import "render" in enzyme for it to check the spacing issue properly
|
A year and a half later I googled and found my own answer. |
@rardoz Thanks. Working perfectly. |
I did a simple test with text() using jest and it was failing unexpectedly:
When I checked I saw that the expect space was
\x20
and the text() space was\xa0
After the some digging I saw that
was translated to\xa0
I saw that text() function for shallow component is normalized and mounted is without nothing
So shallow component handle this problem and also replacing multiple spaces with single one
I thing this behavior should be also for mounted components
The text was updated successfully, but these errors were encountered: