-
Notifications
You must be signed in to change notification settings - Fork 411
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
jest-domversion: 1.0.0
What you did:
// <span>
// Step
// 1
// of 4
// </span>
expect(container.querySelector('span')).toHaveTextContent('Step 1 of 4')What happened:
expect(element).toHaveTextContent()
Expected element to have text content:
Step 1 of 4
Received:
Step
1
of 4
Problem description:
This was initially reported in testing-library/react-testing-library#53, and it was really about a bug in testing-library/dom-testing-library#19. However, this also applies to a piece of code in jest-dom. The custom matchet .toHaveTextContent should also ignore a node's whitespace in its text content before determining if the text matches the expectation.
Suggested solution:
Normalize the text of a node before using to match it with the expected text. Similar to what was done in testing-library/dom-testing-library#19
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers