-
Notifications
You must be signed in to change notification settings - Fork 277
Description
Describe the bug
After migrating from the v7.2 to the 9.0, I had some breaking change in my code
expect(card.queryByText('test. ')).not.toBeNull();
didn't passed anymore. Reading the doc, I tried to use the TextMatch options. But
expect(card.queryByText('test. ', { exact: false })).not.toBeNull();
didn't worked either
After some research and test, I finally found that was because my string needed to be trimmed.
expect(card.queryByText('test. '.trim())).not.toBeNull();
This one worked.
Then, I tried to use the trim option, expect(card.queryByText('test. ', { trim: true })).not.toBeNull();
but it didn't worked either
Expected behavior
expect(card.queryByText('test. ', { trim: true })).not.toBeNull();
should pass
expect(card.queryByText('test. ', { exact: false })).not.toBeNull();
should pass to, since it's presented as a kind of compatibility mode when migrating from v7, and feel like it should be the more permissive thing possible
Steps to Reproduce
This test should pass
import { render } from '@testing-library/react-native';
import { Text } from 'react-native';
describe('test', () => {
it('should pass', () => {
const textWithSpace = 'test. ';
const { getByText } = render(<Text>{textWithSpace}</Text>);
expect(getByText(textWithSpace, { trim: true })).not.toBeNull();
});
});
Versions
npmPackages:
@testing-library/react-native: ^9.0.0 => 9.0.0
react: ^17.0.2 => 17.0.2
react-native: ^0.66.0 => 0.66.3
react-test-renderer: 17.0.2 => 17.0.2