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

Pretty-print React instances. #28

Closed
wants to merge 1 commit into from
Closed

Pretty-print React instances. #28

wants to merge 1 commit into from

Conversation

cpojer
Copy link
Contributor

@cpojer cpojer commented Aug 17, 2016

it('should support a single element with React elements with children', () => {
assertPrintedJSX(
React.createElement('Mouse', {
prop: React.createElement('div', null, 'mouse', React.createElement('span', null, 'rat'))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should maybe test with an array as the child as well

React.createElement('div', null, 'mouse', [
  React.createElement('span', null, 'rat'),
  React.createElement('span', null, 'squirrel')
])

@cpojer
Copy link
Contributor Author

cpojer commented Aug 17, 2016

Ok this works but only for host objects and not for components. When using React.createElement(Button) as a prop, it will print the class source which is definitely not what we want.

@gaearon I think I need more input on this. Should we only print the top level component? @thejameskyle said that a general React printing plugin should be more complex than that but I'd really like to avoid digging into the internal React structure because that will just get us into trouble. Should the test-renderer do something with those and just throw away the instance data?

@cpojer cpojer closed this Aug 17, 2016
@gaearon
Copy link
Contributor

gaearon commented Aug 18, 2016

Let's chat in person. I think you may be confusing elements and instances :-)

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

Successfully merging this pull request may close these issues.

3 participants