Skip to content

Commit

Permalink
Temporarily remove mention of disabling virtualization in docs (#6309)
Browse files Browse the repository at this point in the history
  • Loading branch information
LFDanLu authored May 1, 2024
1 parent 11d2a09 commit 3f646a0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/dev/docs/pages/react-spectrum/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,9 @@ afterAll(() => {

### Virtualized components

Many of our collection components are virtualized out of the box and thus rely on DOM node measurement to know how large a item should be and how many items can be rendered at once. By default, virtualization for these
collection components is turned off by since it is an implementation detail of the component itself and thus doesn't need to be tested by your test suites. However, if you'd like to re-enable virtualization or are running against
an older version of the library that doesn't have this virtualization turned off by default, then you'll have to mock the `clientHeight` and `clientWidth` getters of the `HTMLElement` prototype to get the items of the virtualized collection
to render. `scrollHeight` and `scrollWidth` should also be mocked to set the height and width of each item. See below for an example implementation in Jest.
Many of our collection components are virtualized out of the box and thus rely on DOM node measurement to know how large a item should be and how many items can be rendered at once.
To properly render virtualized components in a test environment, you'll have to to mock the `clientHeight` and `clientWidth` getters of the `HTMLElement` prototype.
`scrollHeight` and `scrollWidth` should also be mocked to set the height and width of each item. See below for an example implementation in Jest.

```tsx
beforeAll(function () {
Expand Down

1 comment on commit 3f646a0

@rspbot
Copy link

@rspbot rspbot commented on 3f646a0 May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.