Value assertion does not work on HTML <select> elements
Closed this issue · 7 comments
pahund commented
If I have this element:
<input value={1} />
This assertion is true, as expected:
element.should.have.value(1)
If I have this element:
<select value={1}>
<option value={1}>1</option>
</select>
The same assertion fails, value is supposedly undefined.
ljharb commented
@pahund because select
doesn't have values, and its value depends on having a selected
<option>
. Try adding selected
to the option tag, and remove "value" from <select>
.
pahund commented
That's what I did at first, but when I do, React gives me a warning message on the console that I should use "value" on my select tag instead of "selected" on an option tag.
pahund commented
ljharb commented
Ah, interesting. In that case I think your expectation (that it works) is reasonable.
ayrton commented