1

While I have had no problems testing other primereact components the VirtualScroller never renders any items. The test below render the wrapper HTML, including a DIV with the class 'p-virtualscroller-content', but never the content.

The same code works fine in a browser.

Is this a bug in primereact or something I am overlooking on the test framework?

const cars = ["Ford"]

const itemTemplate = (item: any, options: any) => {
    return (<div>{item}</div>);
};

render(<VirtualScroller items={cars} itemTemplate={itemTemplate} style={{ width: '200px', height: '200px' }} />);

expect(await screen.findByText("Ford")).toBeInTheDocument();
David Churchland
  • 292
  • 2
  • 11
  • I believe I am close to a work around. It seems the problem is the use VirtualScroller makes of getComputedStyle() and offSetHeight. I poked around in the calculateNumItems inside VirtualScroller and then mocked both getComputedStyle and offSetHeight and my tests started passing. If there is a better way or a fix that can be made to VirtualScroller I would love to hear about it. – David Churchland Jun 23 '23 at 11:48
  • I think your fix sounds valid to me... – Melloware Jun 23 '23 at 15:47

0 Answers0