UI test issue with
See original GitHub issueRecyclerListView doesn’t render any rows when used in a a UI test using ‘react-test-renderer’.
The selected row can’t be found when rendering a list using the RecyclerListView, when moved to FlatList it was rendered nicely and found easily:
const row = ssf.root.findByProps({testID: 'list-row-0'})
<RecyclerListView
{...{refreshControl}}
layoutProvider={this.layoutProvider}
dataProvider={this.dataProvider}
rowRenderer={(type, item) => this.renderRow(item)}
renderAheadOffset={initialNumToRender ? (initialNumToRender * this.rowHeight) : undefined}
extendedState={extraData}
/>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:6
Top Results From Across the Web
5 Common Bugs Faced in UI Testing - BrowserStack
5 Common Bugs Faced in UI Testing · Cross Browser Adaptability Bugs · Form Validation Bugs · Usability Bugs · Inconsistencies in the...
Read more >4 Common UI Testing Problems and How to Solve Them | by Ari
Problems Associated With UI Testing · Constantly Changing UIs · Increasing Testing Complexity · Handling Multiple Errors · UI Tests Can Be Time- ......
Read more >Challenges In UI Testing and How To Fix Them - Hurix Digital
Challenges In UI Testing and How To Fix Them · Data type errors – Ensure that only valid data can be entered for...
Read more >UI Testing: A Beginner's Guide With Checklist and Examples
User interface testing is a crucial type of software testing. Learn how to get started with it with the help of our guide...
Read more >How to solve your UI testing problems - SD Times
The way to do this is to perform UI testing, which ensures an application is performing the right way. “The make or break...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After many hours of trouble shooting on this I found that the issue I was having was that the onLayout event was not being triggered in Jest and the above testing libraries. This meant that the dimensions remained at height and width of 0 and therefore not did not trigger the virtual renderer to update.
I believe that in my case it was because I was using a functional component where the layoutProvider was being updated with useRef below : const _layoutProvider = useRef(layoutProviderMaker()).current
Because it appears that react testing library does not create a specific “current” object related to the ref it therefore did not trigger a layout event.
So my hack was to give the recyclerlistview component a test ID itself “RecyclerListView testID=“recyclerlistview” rowRenderer={rowRenderer} layoutProvider={_layoutProvider} dataProvider={state.dataProvider}”
then once the initial render was set jest needed to capture the recyclerlistview component: const SLCF = getByTestId(“recyclerListView”)
Then the important part was to trigger a layout event: fireEvent(SLCF, “layout”, {nativeEvent: {layout: {height: 781, width: 393, x: 0, y: 0,}}}); and this was enough to get the selected rows to render and pass my tests.
Arguably the above isn’t ideal but I believe it was related to the use of refs in the layout provider but at least it was enough for my purposes.
Hopefully this is applicable to your use case too.
@leonardonelson91 @mdarke1 can we somehow test onEndReach callback getting fired too?