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

Write documentation for react-test-renderer #7431

Closed
KnutHelland opened this issue Aug 5, 2016 · 5 comments
Closed

Write documentation for react-test-renderer #7431

KnutHelland opened this issue Aug 5, 2016 · 5 comments

Comments

@KnutHelland
Copy link

KnutHelland commented Aug 5, 2016

This is the first day I've used react-test-renderer, and I've already stumbled upon three problems:

react-test-renderer is going to be shipped with create-react-app very soon (?) (it's in react-test-renderer@0.3.0-alpha), so I think it deserves some more comprehensive documentation as soon as possible. With at least some troubleshooting bulletpoints and some text about how one are supposed to do with refs.

I sometimes use refs from componentDidMount. For example for setting focus on an input this.refs.input.focus(). But such code will fail with cannot call focus() on undefined. Should we always test if a ref isn't undefined before using them? Or do you have some plans for react-test-renderer in near future that will solve this issue in some way?

@LouisStAmour
Copy link

LouisStAmour commented Aug 7, 2016

I'm hitting the injectEnvironment called twice bug with react-bootstrap and considering my options.

While we're talking react-test-render docs, it may be obvious, but you can't use react-test-renderer with React 0.14 code due to module dependencies, this is more of a Jest documentation bug. jestjs/jest#1364

@gaearon
Copy link
Collaborator

gaearon commented Aug 7, 2016

Please see my replies:

#7386 (comment)
#7371 (comment)

@LouisStAmour
Copy link

LouisStAmour commented Aug 7, 2016

The inject bug is slightly more complicated than #7386 (comment), @gaearon -- I've turned off auto-mocking entirely, and it still happens. Here's some more detail on what's been done/suggested: jestjs/jest#1353 (comment)

@gaearon
Copy link
Collaborator

gaearon commented Aug 7, 2016

I've turned off auto-mocking entirely, and it still happens.

Sorry I wasn’t clear. I’m saying the solution to this is to mock react-dom. This has no relation to automocking. You can turn automocking off (that’s what I’d recommend), but you still need to mock react-dom with an empty mock to get snapshot testing working with react-dom references.

@gaearon gaearon mentioned this issue Oct 23, 2016
13 tasks
@gaearon
Copy link
Collaborator

gaearon commented Oct 23, 2016

Let's track this in #8060.

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

3 participants