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

Workaround for React test renderer not supporting refs #1805

Closed
joshwcomeau opened this issue Sep 27, 2016 · 3 comments
Closed

Workaround for React test renderer not supporting refs #1805

joshwcomeau opened this issue Sep 27, 2016 · 3 comments

Comments

@joshwcomeau
Copy link

Hi,

I'm running into an issue where one of my third-party components uses refs.

This issue has already been explained and closed in #1332, but what wasn't provided was a workaround.

As it stands, snapshot testing is totally broken for the component in question, as well as its parent components. The component in question is a third-party component for integration with MapBox - is there a way to mock out the ref?

How about simply not testing the MapBox component, and mocking out that component for its parent components? I can live with that component not being tested, but I need to be able to test the components further up the tree.

Would appreciate any guidance. Recently came back to Jest after almost 2 years, and it's gotten tons better since then :)

Node v6.2.2, NPM 3.9.5

@cpojer
Copy link
Member

cpojer commented Sep 27, 2016

This will be part of React 15.4: facebook/react#7740

You can do jest.mock('path/to/MapBox', () => 'MapBox') which should completely stub it out.

@cpojer cpojer closed this as completed Sep 27, 2016
@Rolly-luoli
Copy link

@cpojer great, it really help me to resolve the problem. Thanks a lot.

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants