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

renderToString issue with istanbul and function as child components #82

Open
PepijnSenders opened this issue Mar 26, 2019 · 3 comments
Open

Comments

@PepijnSenders
Copy link

PepijnSenders commented Mar 26, 2019

I found this issue whilst comparing snapshots made with jest with and without coverage. When --coverage adds the istanbul babel plugin it adds random elements to the output.

I made a repo where you can see this in action: https://github.com/PepijnSenders/istanbul-preact-render-spy-bug

@PepijnSenders PepijnSenders changed the title renderToString issue with istanbul renderToString issue with istanbul and function as child components Mar 26, 2019
@sventschui
Copy link
Member

What is the intention of passing a function as a child?

What happens here is that the function is serialized to a string and appended to the HTML. Istanbul modifies your code and therefore the string representation of the function looks different.

Either I'm not understanding your usecase or there is an issue with your code. Might you elaborate on your usecase?

Btw. when doing this in react it will not render the function at all. I.e. output would be empty.

@marvinhagemeister
Copy link
Member

@sventschui A common use case is the Consumer component from createContenxt:

<Consumer>
  {contextValue => ... }
</Consumer>

@sventschui
Copy link
Member

Sure but he is passing a function to an HTML element, not to a component. Thus it ends up as text

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