-
Notifications
You must be signed in to change notification settings - Fork 668
Unable to update input value via keydown/keyup/keypress #372
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
Comments
Hi @BeauAgst, thanks for the bug report. Can you make a reproduction using this JSFiddle as a base: https://jsfiddle.net/eddyerburgh/sghur81m/3/ |
@eddyerburgh apologies - https://jsfiddle.net/xvL6q27m/ I've updated the original issue to this link |
No problem! It takes a bit of setup in JSFiddle. Thanks for the reproduction. With a value, you need to set it on the element: wrapper.element.value = '' Then you can trigger an event that uses the value: wrapper.trigger('keydown') However, there's a problem with v-model, where changing the value isn't picked up by the model value—#345. We're working on a fix |
Thanks for the prompt reply @eddyerburgh That's fine, and how I was originally doing it for my What would your recommendation be on how to test that method? Am I correct to assume I won't be able to test it until that bug is fixed? Thanks! For example: https://jsfiddle.net/bj81bhwo/ |
Yeah sorry, there isn't currently a way to test that. One method I can think of is to allow you to pass a custom Event to trigger, then you could test that preventDefault was prevented. If you'd like to use this feature, please make a feature-request issue 😀 |
Is there a way to test this now? I'm using vue-testing-libarary and saw a reference that the dom inputs cannot be updated due to a bug in vue-test-utils. https://github.com/dfcook/vue-testing-library/blob/master/tests/__tests__/form.js
I'm also curious to know why the update to the dom node doesn't update the state? Because the values changed in the application via a browser does work fine. |
Version
1.0.0-beta.10
Jest 22.0.4
Reproduction link
https://jsfiddle.net/xvL6q27m/
Steps to reproduce
Test attached component using Jest, and vue-test-utils
What is expected?
The
value
inside the data of the component should update, and bea
.What is actually happening?
Nothing, the
value
doesn't change, and theinput.element.value
is also empty. The test always fails.I tested this with beta.9, and then again with beta.11 (not on the list)
The text was updated successfully, but these errors were encountered: