Testing a table that uses virtual with React Testing Library
I have a component that is using
react-virtual
and it works as expected in the UI but when testing I see that the getVirtualItems
returns an empty array.
Can someone please provide an example for testing using Jest and/or RTL? I can't share code because it is confidential but I think my description is as clear as possible. Thanks!2 Replies
fascinating-indigo•14mo ago
Hi, you need to moc the scroll element to return some height, https://github.com/TanStack/virtual/issues/641#issuecomment-1875566247
GitHub
No rows returned by useVirtualizer in unit tests · Issue #641 · Tan...
Describe the bug In browser table rows are rendered as expected. In unit tests useVirtualizer returns an empty array from rowVirtualizer.getVirtualItems(). The bug is introduce with changes introdu...
afraid-scarletOP•14mo ago
Thanks!