-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Discussion: pretty-format with React element of type undefined renders Unknown in snapshot #3823
Comments
We'll keep using this for now. |
@cpojer Could you provide the reasoning, just for my curiosity? |
Components can be nameless, and we fill in an unknown name, which is similar to what React also does. |
I understand that for valid, renderable components, but can components be undefined? Seems you could get the best of both worlds by adding an explicit check for undefined/invalid nodes. |
cc @pedrottimark I'll defer to you. |
@nathanforce Thank you for your patience until we could think how to sort it out in #4360 |
Do you want to request a feature or report a bug?
feature/discussion
What is the current behavior?
When creating a snapshot with an undefined component, the snapshot will use
<Unknown>
.(https://github.com/facebook/jest/blob/master/packages/pretty-format/src/plugins/ReactElement.js#L84).
I am wondering if this is an intentional implementation, as it leads to easily missed mistakes when using static subcomponents a la Semantic UI.
As an example, if you were to make a typo as below (Message.Haeder), your snapshot would still render and the mistake could be easily missed.
What is the expected behavior?
Would it be better to error when trying to render a React element of type undefined or is that outside the scope of pretty-format?
The text was updated successfully, but these errors were encountered: