Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with React Testing Library #316

Open
charlieforward9 opened this issue Apr 3, 2024 · 0 comments
Open

Incompatibility with React Testing Library #316

charlieforward9 opened this issue Apr 3, 2024 · 0 comments

Comments

@charlieforward9
Copy link

Description

Rendering a simple <ReactSlider ... /> with React Testing Library:

const slider = screen.getByRole("slider");
const currentValue = slider.getAttribute("aria-valuenow");
console.log(currentValue); // Logs '2'
fireEvent.change(screen.getByRole("slider"), {
  target: { value: { now: Number(currentValue) - 1 } },
});

This fails with the error The given element does not have a value setter. (I tried a ton of workaround inputs, such as target: {value: ... } }, value: { },, value: { now: {...}}

It would be nice to be able to test the onChange functionality nested within this component without having to engage in tedious workarounds.

CodeSandbox

TODO: I will get to this when I get a little more time Edit zillow/react-slider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant