-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
TestUtils.renderIntoDocument doesn't function as expected in all browsers #3789
Comments
I get it now.
Appending to the document was commented out in this commit: ce95c3d. I guess the bigger issue is this method is a misnomer, as it doesn't actually render into the document. It certainly fooled me. |
I don't feel strongly. |
I suppose we have two options:
or,
Option 1 seems like the best option at this point, as |
From facebook/react#3789 in Webkit and Psuedo-Webkit browsers calling setSelectionRange on an input not currently in the document is fine, but breaks in Firefox and IE with a rather nasty error.
@ezequiel how do you feel about the following
We're running into problems when trying to test the dimensions of a component i.e. |
We could even make ReactTestUtils.renderInto(
<MyComponent>Hello!</MyComponent>,
document.querySelector("#fixtures"),
function(componentElm) {
expect(componentElm.innerHTML).to.contain.text("Hello");
}
}); |
This is definitely a problem for accessibility testing. We need components to be attached to test them fully, as the current method makes the tree appear to be hidden. It would be really helpful to have blessed methods for doing this, as appending to the body and then removing messes up my other tests with "The DOM was unexpectedly mutated" errors. |
@marcysutton Thanks, that's useful feedback. If you do need to append to the document then the most straightforward and flexible solution is to call ReactDOM.render manually:
That's also exactly what the implementation of any test helper we might provide would do. |
@sophiebits Thank you for this suggestion to use |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
Hi,
Here is my program (jsfiddle):
Problem:
0
is logged twice in Chrome and Firefox.What I expected:
3
is logged twice. We see this in Safari.The interesting part is if we use
React.render(..., document.body)
instead ofTestUtils.renderIntoDocument
the program works as expected.I am using:
The text was updated successfully, but these errors were encountered: