-
Notifications
You must be signed in to change notification settings - Fork 277
Closed
Labels
good first issueGood for newcomersGood for newcomers
Description
Describe the bug
New lines, that are rendered in RN as separate Lines, are wrongly normalised during testing.
const { queryByText } = render(<Text>Line 1\nLine 2</Text>)
expect(queryByText("Line 1\nLine 2")).toBeDefined()
Expected behavior
I expect the test to pass.
I have checked the queryByText and it seems it uses the same normaliser (Default) as the findTextByNode so this should actually work.
I know that in HTML whitespace is ignored and normalised by browsers to one space. But in RN it actually matters and is rendered (at least \n whitespace).
The test can be made to pass by this change:
-expect(queryByText("Line 1\nLine 2")).toBeDefined()
+expect(queryByText("Line 1\nLine 2".split("\n").join(" ")).toBeDefined()
which indicates to me, the queryByText does in fact not normalises the input query text correctly.
Versions
npmPackages:
@testing-library/react-native: 9.0.0 => 9.0.0
react: 17.0.2 => 17.0.2
react-native: 0.66.3 => 0.66.3
react-test-renderer: 16.14.0 => 16.14.0
ManuViola77 and takeItIzzy
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers