Comments (3)
So for the testing I actually need to add: { includeHiddenElements: true }
as option for the getters in order to make this work!
import { render } from '@testing-library/react-native';
import { Text, View } from 'react-native';
const MyComponent = () => {
return (
<View accessibilityElementsHidden importantForAccessibility="no-hide-descendants" testID="View">
<Text>Hello World</Text>
</View>
);
};
it('Can Render component and get text', () => {
const { getByText } = render(<MyComponent />);
expect(getByText('Hello World', { includeHiddenElements: true })).toBeTruthy();
});
it('Can Render component and getByTestId', () => {
const { getByTestId } = render(<MyComponent />);
expect(getByTestId('View', { includeHiddenElements: true })).toBeTruthy();
});
That will do the trick
from react-native-testing-library.
@berseck. @wilsolutions You seem to figure out the issue yourself. ❤️
From my side I can add that we are not matching the hidden elements as they would not be "seen" by the user. However, we also provide the includeHiddenElements
option as a way to avoid that.
from react-native-testing-library.
Interesting, I was about to post this, I've the same issue...
from react-native-testing-library.
Related Issues (20)
- Incorrect automatic cleanup order HOT 2
- Why are accessibilty elements only text, textInput, and switch? HOT 13
- Getting "ReferenceError: jest is not defined" when on userEvent touch events HOT 9
- I am having non deterministic error after migrate to v12.4.0 HOT 13
- RN 0.74 breaking testing library HOT 10
- RFC: impact of `detectHostComponentNames` HOT 5
- waitForElementToBeRemoved doesn't work as expected with `get` type queries HOT 2
- Unexpected behavior of userEvent.press with timers HOT 1
- How to test userEvent.press() in combination with precise timers advancing? HOT 5
- Vitest support HOT 4
- `persist` method does not exist on event passed to onKeyPress HOT 3
- RFC: React 19 support HOT 6
- React 18 support HOT 7
- unstable_validateStringsRenderedWithinText immediate setState in useEffect HOT 3
- toHaveTextContent matching rules are not aligned with jest-dom HOT 2
- Configuration option for customizing error output
- act is deprecated HOT 3
- RFC: RNTL Cookbook HOT 4
- Unexpected token 'export' error when running Jest tests HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-testing-library.