Skip to content
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

React Test Renderer: Add createRef() example for createNodeMock #1035

Open
Awem opened this issue Jul 4, 2018 · 4 comments
Open

React Test Renderer: Add createRef() example for createNodeMock #1035

Awem opened this issue Jul 4, 2018 · 4 comments

Comments

@Awem
Copy link

Awem commented Jul 4, 2018

https://reactjs.org/docs/test-renderer.html#ideas demonstrates how to use createNodeMock to mock a callback ref. However, this example does not work for refs create with React.createRef(), because they use the current property. Could you extend the documentation please?

@META-DREAMER
Copy link

Need this badly, impossible to test components without it in TypeScript since we pretty much need to use React.createRef().

@Awem Did you come up with a solution?

@JeyashreeA
Copy link

Hi, is there any solution or alternative for this? Could be really useful.

@pierreferry
Copy link

I managed to test my component using Enzyme. Sadly i could not make it with react-test-renderer

@Awem
Copy link
Author

Awem commented Aug 2, 2019

Hi, I am actually not using createNodeMock anymore. Instead, I refactored the tested component to use the useRef hook. That works quite fine. I don't need mocks anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants