-
-
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
Stubbing an instance method requires component and wrapper updates #586
Comments
I'm also seeing this - thanks for the workaround. Possibly related to #622? |
Any updates on this? |
I wouldn't expect the wrapper to rerender unless props or state had changed. Your best bet is to stub the method on MyForm.prototype before shallow-rendering, rather than waiting till you have the instance. |
seems to come down differences between shallow and mount |
It does not work for me. In my case onSubmit undefined, even when I passed the handleSubmit to props.
|
@palaniichukdmytro that's because you're putting arrow functions in class properties; that makes them slower and harder to test. All of those should be instance methods, and you should |
No worries guys! You could mock anything : and no need for
So it can be:
Enjoy! |
@abdennour to be clear, your method works on |
@antgonzales @abdennour method does work with shallow, you just have to call |
This seems resolved; happy to reopen if not. |
Hi. I have a simple presentation component who's instance method (i.e. handler) I'm trying to assert is actually called.
I'm grabbing an instance of the component and then stubbing the handler via sinon. I was expecting to then be able to call
update
on the wrapper, simulate an action, and then assert that the stub was actually called.However, the stub never gets called...unless I also call
forceUpdate
on the component instance. Wondering if this is an issue withupdate
or is expected behavior?EDIT / Note: handleSubmit is being passed in as a prop which then takes as an argument the instance method handleSubmit because this is a redux-form.
Here's the example presentation component:
Here's the example test:
The text was updated successfully, but these errors were encountered: