Skip to content

Commit 6f65d53

Browse files
committed
test(matchers/to-have-text-content): verify element has expected text content
1 parent 44533c7 commit 6f65d53

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as React from 'react';
2+
import { Text, View } from 'react-native';
3+
4+
import { render, screen } from '../..';
5+
6+
it('verifies element has expected text content', async () => {
7+
const Component = () => (
8+
<View>
9+
<Text testID="text-element">Hello World</Text>
10+
</View>
11+
);
12+
13+
await render(<Component />);
14+
15+
const element = screen.getByTestId('text-element');
16+
expect(element).toHaveTextContent('Hello World');
17+
});

test-coverage-progress.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ test(user-event/paste): Validates userEvent.paste() pastes text into TextInput r
2020
test(matchers/to-have-accessible-name): Validates toHaveAccessibleName matcher checks if element has accessible name via accessibilityLabel - critical matcher users depend on for testing accessibility where accessible names identify elements for screen readers. Coverage: 77.27% statements (was 20.45%), 40% branches, 50% functions for to-have-accessible-name.ts. Covered main matcher function, computeAccessibleName call, name matching with expected value, presence check without expected value. Uncovered: error message formatting (lines 33-42).
2121
test(wait-for-element-to-be-removed): Validates waitForElementToBeRemoved resolves when query throws error after element is removed - critical behavior users depend on when elements are removed from DOM and queries throw. Coverage: 95.23% statements (was 61.9%), 80% branches, 100% functions for wait-for-element-to-be-removed.ts. Covered wait logic with error handling when expectation throws (lines 28-41), catch block that returns initialElements when element removed. Uncovered: lines 39-40 (edge case in removal detection).
2222
test(matchers/to-have-style): Validates toHaveStyle matcher checks if element has expected style properties - critical matcher users depend on for testing styled components and verifying UI styling. Coverage: 51.38% statements (was 29.16%), 50% branches, 20% functions for to-have-style.ts. Covered main matcher function, style flattening, property comparison logic. Uncovered: error message formatting paths (success case lines 27-41, failure diff lines 48-51, helper functions lines 56-72).
23+
test(matchers/to-be-busy): Validates toBeBusy matcher checks if element is busy via accessibilityState - critical matcher users depend on for testing loading states in components. Coverage: 66.66% statements (was 37.5%), 100% branches, 50% functions for to-be-busy.ts. Covered main matcher function, computeAriaBusy logic, busy and not-busy states. Uncovered: error message formatting (lines 15-22).
24+
test(matchers/to-have-text-content): Validates toHaveTextContent matcher checks if element has expected text content - critical matcher users depend on for verifying text content in components. Coverage: 69.69% statements (was 27.27%), 33.33% branches, 50% functions for to-have-text-content.ts. Covered main matcher function, text content retrieval and matching. Uncovered: error message formatting (lines 22-31).

0 commit comments

Comments
 (0)