I'm trying to access the placeholder text in this form input tag, just to validate that the text is correct:
<form>
<input name="form" className="form-classname" placeholder="Text inside placeholder"/>
</form>
I'm shallow rendering this component, and have tried this, but since this is placeholder and not text, the node is returning an empty string as input (as would be expected).
expect(wrapper.find('.form-classname').at(0).text()).toEqual('Text inside placeholder')
Suggestions on what to try next?
As of the current version of the testing library, you can now simply use the ByPlaceholderText API to do this: https://testing-library.com/docs/queries/byplaceholdertext/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With