-
Notifications
You must be signed in to change notification settings - Fork 458
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
Change on select not changing selected value #256
Comments
I’m having the exact same issue. |
Can you post the output of |
Actually the debug output won’t help much, nevermind. There’s no code pen to work off of but I’m going to say your problem is probably that you’re firing a change event at the container rather than on option within the select itself. Firing at the container rather than an option in the select means there’s no valid handler for the event to bubble to. |
Here's a version of how my code looks: https://gist.github.com/johnridesabike/ce8f7ac63cc07838185b54aa894989b4 If you run the test, it will fail with the output:
Note that the I tried using Am I just doing it wrong? What would be the correct way of doing this? |
@johnridesabike Here's a CodeSandbox working with your example from above. Good luck! |
@bcarroll22 Thank you! I can see exactly what I was doing wrong. All of my tests are working as expected now. In case anyone reading this has a similar problem, they key detail I missed was |
@phc5 is this issue resolved for you as well? I’d like to go ahead and close this issue if you’re all set. |
@bcaroll22 yes! Thank you both for your responses |
|
dom-testing-library
version: 4.0.0node
version: 9.8.0npm
(oryarn
) version: 5.6.0Relevant code or config
Uing
react-testing-library
but the issue happens indom-testing-library/dist/events.js
What you did:
I called
fireEvent.change()
, on a select element to change its value but the value does not change (stays initial selected value).What happened:
In
dom-testing-library/dist/events.js
line 572, when constructing new event usingEventConstructor()
, the returned event.target is null despite passing in the arguments: eventName =change
and eventInit ={ bubbles: true, cancelable: true, target: { value: 'priceasc' }
.It hits
onChange
callback in my React component, butevent.target.value
is the initial valueThe text was updated successfully, but these errors were encountered: