[slider] Targeting the Thumb properly in a Jest/Vitest environment
- Dominant language
- TypeScript
- Stars
- 10.9k
- Forks
- 543
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 101
Description
# Get help
## Ask a question
Developers using our Base UI based design system were confused as to why in order to select a `Slider.Thumb` in a test, one must use `{ hidden: true }`:
```
expect(screen.getByRole('slider', { hidden: true })).toBeInTheDocument()
```
I noticed these lines must be the cause: https://github.com/mui/base-ui/blob/master/packages/react/src/slider/thumb/SliderThumb.tsx#L251-L254
```
return {
['--position' as string]: `${positionPercent}%`,
visibility:
(renderBeforeHydration && !isMounted) || positionPercent === undefined
? 'hidden'
: undefined,
```
I can't explain why this condition exists and if there is a way around this to keep our tests clean (and avoid using `{ hidden: true }` ?
Contributor guide
Assessment
This issue has not been assessed yet.