-
Notifications
You must be signed in to change notification settings - Fork 403
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
toHaveSelectionValue #289
Comments
This could be a nice addition indeed. One thing I'd suggest is discuss the name a bit. |
I'd be fine with just |
I think I also thought about |
Sure. Selection makes more sense than selected. |
Hello, I would like to try to implement this one if it is still needed. |
Hey @pwolaq @gnapse I encountered a use case for testing the selection in a work project, and while I managed to perform the testing with attributes such .selectionStart and .selectionEnd, I found this issue and the PR from a few years back, and decided to revive it and finish it so we can merge it to the library. Could you help me out with a review, please? Let me know if you need more changes or info. Thanks! |
This new selector is about to be released (see #637). Thanks to @pwolaq and @silviuaavram! And thanks, @diegohaz, for the proposal. |
@all-contributors please add @diegohaz for ideas |
I've put up a pull request to add @diegohaz! 🎉 |
Describe the feature you'd like:
I'm testing a combobox element with a behavior that is quite similar to the address bar in the browser. That is, when you start typing, it automatically completes the text with the first suggestion and highlights the completion string.
I would like to test this selection behavior.
Suggested implementation:
Describe alternatives you've considered:
I can check the
selectionStart
andselectionEnd
properties on theHTMLInputElement
, but this is not as easy to read. And I also have to explicitly cast the element if I'm using TypeScript.So, for now, I'm using an
expectSelectionValue
util function in my app.Teachability, Documentation, Adoption, Migration Strategy:
toHaveSelectionValue
This allows you to check whether the given textbox element has the specified selected (highlighted) value. It accepts
<input type="text">
and<textarea>
elements.Examples
Using DOM Testing Library
The text was updated successfully, but these errors were encountered: