-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Show a friendly error when using TestUtils.Simulate with shallow rendering #5284
Comments
I'm not up to date with what the interaction is supposed to be with the shallow renderer these days so cc @spicyj … But when you use the shallow renderer you aren't working on a real rendered tree. So as your test case seems to be written, yes this is expected. |
That's expected. We should probably give a better error message – changing this issue title to reflect that. |
Is there anything I can do to help with this? I haven't contributed to React yet, but we're investing heavily into in-company knowledge. If you can point me to where to assert this, I'd love to help. |
Also, where do I submit PR's for React's website? I could clarify this in the documentation... |
The docs/ directory has markdown files that turn into the website. Each page should also have an "Edit on GitHub" button at the top that links you straight to it. In the ReactTestUtils.js file, you could add an invariant that makes sure React.isValidElement returns false on the passed-in node. |
…ate-shallow-render #5284 - Show a friendly error when using TestUtils.Simulate with shallow rendering
I'm doing a simple shallow render on a component which has a button (
<a>
) with anonClick
handler. I can correctly assert most of its properties, but I can't get asserting whether the button has been clicked (by usingTestUtils.Simulate.click(output.props.children[1])
and asinon.spy()
passed in as handler) to work. TestUtils doesn't throw any Invariant Violation or whatever other error, the spy just never gets called. When I manually call it throughthis.props.children[1].props.onClick()
it works. Is this expected behavior?The text was updated successfully, but these errors were encountered: