mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
test(matchers/to-have-text-content): add negative (.not) variant test
This commit is contained in:
@@ -7,11 +7,16 @@ it('verifies element has expected text content', async () => {
|
||||
const Component = () => (
|
||||
<View>
|
||||
<Text testID="text-element">Hello World</Text>
|
||||
<Text testID="other-element">Other Text</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
await render(<Component />);
|
||||
|
||||
const element = screen.getByTestId('text-element');
|
||||
const otherElement = screen.getByTestId('other-element');
|
||||
|
||||
expect(element).toHaveTextContent('Hello World');
|
||||
expect(element).not.toHaveTextContent('Other Text');
|
||||
expect(otherElement).not.toHaveTextContent('Hello World');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user