question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UI test issue with

See original GitHub issue

RecyclerListView 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:open
  • Created 3 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

2reactions
mdarke1commented, Jun 7, 2021

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.

0reactions
callmemonkycommented, Jan 13, 2022

@leonardonelson91 @mdarke1 can we somehow test onEndReach callback getting fired too?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found