-
Notifications
You must be signed in to change notification settings - Fork 472
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
Utilities for dispatching events? #5
Comments
How about keeping it similar to react-dom's simulate.click(getByTestId('submit-button'))
// or even keep it capitalized
Simulate.change(
document.querySelector('input[name="username"]'),
{ target: { name: 'username', value: '1234' } },
) It could also be a single function, and the event type as parameter: simulate('click', getByTestId('submit-button')) Though I'd prefer the former option. |
I also prefer the former option. But let's call it fireEvent.click(domNode)
// the `change` event in react is actually the `input` event.
// the actual change event only fires on blur for inputs
// https://developer.mozilla.org/en-US/docs/Web/Events/change
// https://developer.mozilla.org/en-US/docs/Web/Events/input
// we'll need to document this in react-testing-library with big bold letters.
fireEvent.input(
document.querySelector('input[name="username"]'),
{target: {name: 'username', value: '1234'}}
) If we can find a module with list of all events that would be super. Then we could use that to generate these. Alternatively, we could use a Proxy, which would probably be really handy. That actually could be preferable... 🤔 |
Hey @kentcdodds, this is something I'm using for preact test library:
found it working in most of the cases. Also if we want to extend supporting But again, as discussed in twitter, it might not serve all the purposes. |
Thanks @antoaravinth. That wont quite be enough because it doesn't allow you to specify custom options (as in the |
@kentcdodds so funny story. i literally worked on a similar library last week and just found out about your project https://github.com/jomaxx/react-dom-test-env. I have a I also have a let me know if i can help |
Oh hey! That's so cool @jomaxx! I'd love to join forces! How would you like to make a PR that adds your simulate functionality to this library? I think it'll need a few changes (change it from About the It's validating to me that you were working on something similar recently @jomaxx! I hope we can work together to make testing React (and DOM related stuff in general) really awesome! |
@kentcdodds will do! |
Maybe you could also use something like: https://github.com/PolymerElements/iron-test-helpers |
I think we're covered. And this was actually addressed and merged so we're good with this issue! Thanks though @igomezal! |
I'm thinking there could be room for a utility for dispatching events in elements. Similar to react's test utils Simulate utilities except with actual browser events. What should the API look like?
The text was updated successfully, but these errors were encountered: