Closed as not planned
Description
Hey hey, long time not posted here^^'
Describe the bug
toHaveTextContent()
does exact matching by default, while the same helper exposed by jest-dom does partial matching.
test('toHaveTextContent() does exact match by default', () => {
render(<Text testID="text">Hello World</Text>);
const text = screen.getByTestId('text');
expect(text).toHaveTextContent('Hello World');
// this will error with jest-dom when using RTL.
expect(text).not.toHaveTextContent('Hello');
expect(text).not.toHaveTextContent('World');
});
Expected behavior
I would expect both APIs to behave similarly. Furthermore, the jest-dom
matcher doesn't support the exact
option, which makes it a bit hard to run both web and native tests with the same code.
I'll happily open a conversion in jest-dom's repo, but we should be sure of what we want before hand. Have you had discussions with them on this topic?
Metadata
Metadata
Assignees
Labels
No labels