-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Jest spyOn React.createRef() not working as expected #10392
Comments
I also am having issues with this.
Still testing, haven't figured out the problem yet :( |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I've been using React.createRef on one of my components, and using ref.current.validate() & current.state which works fine on implementation but not while testing it using Jest. jest.spyOn works on validate() function but loses all other props of ref such as 'state' here. Also using Enzyme Mount for the component render.
jest.spyOn(React,'createRef').mockReturnValue({ current: { validate: jest.fn(), state: 'abc' } })
The text was updated successfully, but these errors were encountered: