-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Why to avoid .simulate? Rather use props
to call fn directly?
#1606
Comments
My understanding is Jest/enzyme is using JS DOM, which is not real DOM, it has problem mocking browser event. There is a brief Gotchas section at the end of the
http://airbnb.io/enzyme/docs/api/ShallowWrapper/simulate.html |
Copied from https://github.com/airbnb/enzyme/issues/1054 |
This seems answered. |
Hello, @ljharb, I have a question for you, if you don't mind. I saw you were saying that it's better to invoke functions directly, without simulate, so what would be the proper way to test onChange event with an event parameter? Is it enough to check if it was called or there is more that has to be done? I would appreciate your advice, thanks. |
@LukasZvikas you don't need to test the event, you need to test the onChange handler. So, you'd do |
@ljharb if our event handler calls |
@jedwards1211 pass |
@ljharb okay, really I was just wondering if we could call whatever |
@jedwards1211 note that |
@ljharb huh, I only ever use |
Nothing has changed with |
Well, this is not exactly an issue but a question.
I face the same issue as others had face like:
#1473
#1081
Interestingly, most of the comments suggest that:
Yes, the suggested method works, but I just wanted to understand why that is the case? Is that something enzyme can't do well or enzyme actually uses
React.simulate
under the hood, which has these problems? Also can't we usedispatchEvent
on that element? What your thoughts on this?Thanks for your time on this.
The text was updated successfully, but these errors were encountered: