-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Form Inputs not updating after change event is fired #152
Form Inputs not updating after change event is fired #152
Comments
Hi @pcfields, Thanks for this. Please ping in here when you've added the minimal reproduction codesandbox. I definitely want to improve this so testing this kind of experience is more obvious. FWIW, |
@kentcdodds I've updated the codesandbox https://codesandbox.io/s/0xwn98wo1p |
Let me know how I can help you fix this? This is my first ever Github issue or contribution so i'm more than happy to help |
Sounds great! Could you strip down your example to be as minimal as possible? The less code in there to reproduce the issue the better as it makes it easier for us to determine what could cause the issue. |
@kentcdodds I've stripped down the code. Let me know if this is enough. |
Let's try for something even simpler: https://codesandbox.io/s/2pokxwn2y0 I try to reduce it down to the smallest possible amount of code to still reproduce the bug :) |
Ok, so I'm pretty sure that if we just remove this code we're golden. I didn't put that code there and I didn't quite understand why we needed it in the first place. But if I remove it then that test case works. Can you try removing that code from your |
@kentcdodds Yes. But I remember, we had the discussion on the same lines of code before somewhere, I tried to search our issues/PR but no luck. Looks like Jomaxx have added these files, when we moved from React Simulate to native events. Not sure the reason behind it. @jomaxx any reasons? |
👋 Hello, I’m traveling today but can take a look sometime next week. If
removing the code doesn’t break tests then I say go for it.
…On Sat, Aug 4, 2018 at 9:59 AM antsmartian ***@***.***> wrote:
@kentcdodds <https://github.com/kentcdodds> Yes. But I remember, we had
the discussion on the same lines of code before somewhere, I tried to
search our issues, but no luck. Looks like Jomaxx have added these files,
when we moved from React Simulate to native events. Not sure the reason
behind it. @jomaxx <https://github.com/jomaxx> any reasons?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#152 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACnsIBMf9KmMfhOewUg4Y15tMof0KxDvks5uNWJzgaJpZM4VupTF>
.
|
Hi friends! So it doesn't quite do it for us. Test cases definitely fail because even though the value does change, the event handlers are not called. I've figured out a way to fix this for I've opened a PR for this in |
@pcfields, if you'd like to open a PR that makes this work in We'll definitely want some good comments for this though... |
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
@kentcdodds I am only now seeing your message. What would you like me to do? |
Could you review this: testing-library/dom-testing-library#85 Thanks! |
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
Ok, so this bug happened due to the way React works, and now dom-testing-library's Here's how you use it: https://codesandbox.io/s/github/kentcdodds/react-testing-library-examples/tree/master/?module=%2Fsrc%2F__tests__%2Fon-change.js&previewwindow=tests Here's the basic example: fireEvent.change(passwordInput, {target: {value: '12345678'}}) 🎉 Thanks! Now we gotta figure out how to help people avoid this in the future 🤔 |
Is that now the recommended way to change an input value then? Should the readme be updated? |
Yes, if you're going to fire a change event then that's how the value should be changed. Otherwise manipulating the value should work fine. |
Hmm, should this work with the latest version of this package on npm? It's not for working for me |
Please be more specific @weyert. A reproduction would be helpful. |
@kentcdodds Sorry, I am was goofing up! Checked the wrong form field! All working as expected. Amazingly awesome :D 🎉 |
This should definitely be added to the README file. |
It is in the readme. Search for the string "fireEvent.change" in the README, and you'll find this:
|
Hey, this fixes small typo in `README.md` in function parameters example for `getText`. <!-- Thanks for your interest in the project. Bugs filed and PRs submitted are appreciated! Please make sure that you are familiar with and follow the Code of Conduct for this project (found in the CODE_OF_CONDUCT.md file). Also, please make sure you're familiar with and follow the instructions in the contributing guidelines (found in the CONTRIBUTING.md file). If you're new to contributing to open source projects, you might find this free video course helpful: http://kcd.im/pull-request Please fill out the information below to expedite the review and (hopefully) merge of your pull request! --> <!-- What changes are being made? (What feature/bug is being fixed here?) --> **What**: Documentation typo. <!-- Why are these changes necessary? --> **Why**: So documentation is more precise :) <!-- How were these changes implemented? --> **How**: <!-- Have you done all of these things? --> **Checklist**: <!-- add "N/A" to the end of each line that's irrelevant to your changes --> <!-- to check an item, place an "x" in the box like so: "- [x] Documentation" --> - [x] Documentation - [ ] Tests N/A - [x] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? --> - [ ] Added myself to contributors table <!-- this is optional, see the contributing guidelines for instructions --> <!-- feel free to add additional comments -->
Closes testing-library#152 BREAKING CHANGE: disabled or readonly inputs won't be typeable anymore
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
Specifically this is so the change event can set the value of the node in a way that works for React (and all other frameworks and non-frameworks) nicely. fixes: testing-library/react-testing-library#152
react-testing-library
version: 4.1.5react
version: 16.4.1node
version: 8.6.0npm
(oryarn
) version: 6.2.0Relevant code or config:
What you did:
Test a sign in form by setting username to '[email protected]' and password to '12345678'
What happened:
When updating 2 inputs in a test, only one input gets updated the second input's value is ' ' (empty)
Reproduction:
https://codesandbox.io/s/0xwn98wo1p
Problem description:
I can't test forms with more than one field change
Suggested solution:
The text was updated successfully, but these errors were encountered: