`.toHaveValue` expect string values for input type range
@testing-library/jest-domversion: 5.11.9nodeversion: 12.16.0npm(oryarn) version: 1.22.5
Relevant code or config:
const MyComponent = () => <input data-test="input" type="range" value={5} onChange={() => {}} />
it('should work', () => {
render(<MyComponent />);
let inputRange = screen.getByTestId('input');
expect(inputRange).toHaveValue(5);
});
Hey there ! I just stumble upon a strange case were testing value for a input type range expect values to be string. I find it quite odd since those input value are always numbers.
Reproduction:
Here is a minimap repro in a codesandbox https://codesandbox.io/s/react-testing-library-demo-forked-pve4d?file=/src/tests/hello.js
Problem description:
.toHaveValueexpect string values for input type range
It force the test to use strings instead of number. It is annoying when dealing with const that are numbers.
Suggested solution:
.toHaveValuecould expect number values for input type range
I may open a PR for that if you can point me where the job is done for input type="number" :+1:
Thanks for your bug report. Indeed, this should work the same as with <input type="number" />. Here's where we treat numeric inputs differently: https://github.com/testing-library/jest-dom/blob/637529e3892611092671f30c135587c130fbf92d/src/utils.js#L191-L192