-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Snapshot with instrumentation code in it?? #1780
Comments
This is really odd. Some other people reported this as well and I thought it was something they did wrong. Jest hasn't published a release in a while as we are working on 16 so I'm wondering if there is any change in istanbul or react that went out in a patch release that is causing this issue? |
That could be it I suppose. It seemed to happen when I started using |
It might be a bug in enzyme-to-json then? |
My guess is it has something to do with pretty-format either not getting the right arguments passed to it, or breaking something. I looked at |
I'm having the same issue where It seems it only happens when there is a function passed as a prop. |
Sounds like it is a problem with |
I got it for |
Hi, I'll have a look as soon as I can 🤔 (probably on monday, sorry) |
A very similar issue has been raised here, so it's more likely to be an problem with enzyme-to-json than Jest. I'm looking at it, you can probably close this bug, since one has been raised there on our repo. |
@adriantoine can you ensure you'll try with latest version of Jest? |
I think those are separate issues. One is that The other is that our custom serialization format used to print function names. We don't invoke I'm wondering whether the issue here is that we have "functions" that don't identify themselves as functions or we might call |
I think I found where is the issue in For example this won't work: export class ClassWithDirectPure extends Component {
render() {
return (
<BasicPure className="nested-pure">
<span>{this.props.children}</span>
<span className="empty"></span>
</BasicPure>
);
}
} But this will work: export class ClassWithPure extends Component {
render() {
return (
<div>
<BasicPure className="nested-pure">
<span>{this.props.children}</span>
<span className="empty"></span>
</BasicPure>
</div>
);
}
} I'm working on a fix. |
I'm about to publish a fix for this issue (see adriantoine/enzyme-to-json#16) @kentcdodds |
@kentcdodds the fix is in |
Thanks! Though, I think that Jest no longer will include function names in 16.0.0 which means this shouldn't happen anymore anyway :-/ |
@kentcdodds could be different. see comment above |
I don't think this is related or could be fixed by Jest 16, it's an internal issue of Either way this shouldn't happen anymore 😛 |
well. this is still happening for me with |
@adriantoine thanks for fixing it in enzyme-to-json. @bsr203 if this is happening to you with react-test-renderer, please provide a repro. |
Here is a minimal reproducing case for the way I just saw this in a snapshot test of shallow-rendered output with TestUtils (no Enzyme). Maybe a false start? It almost worked :) https://github.com/pedrottimark/jest-1780 see Forgot to mention: Node 7.2.0 and a snapshot with react-test-renderer works as expected. |
Correct output after I updated dependencies to react-scripts 0.8.1 and Jest 17.0.2 |
@bsr203 Hello, how is it going? Is it still a problem with current versions of React and Jest? It looks like the problem that you reported is the only one still unresolved on this issue. Although your problem sounds different, upgrading dependencies solved my problem. |
Sorry, I havn't tried last few weeks, and the latest update might have solved it. Will try out and get back in couple of days. thanks. |
Closing as this looks like resolved now. Happy to reopen if the problem still exists for @bsr203 |
@thymikee I can confirm that, it is solved for me with both |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
My snapshots have code and istanbul annotations in them... I can't explain it. I've dug for a few hours... Not sure what's going on. I'm using enzyme + enzyme-to-json by @trayio and it's just the weirdest thing...
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can
npm install
andnpm test
.You can clone this repo (note the
help/weird-stuff
branch). Then runnpm run setup
which will install all deps and run the validate script. Then openexercises-final/containers
and you'll see all the relevant stuff in there.What is the expected behavior?
It should be formatted nicely and not have instrumentation code in the output. Should just be good-looking JSX
Run Jest again with
--debug
and provide the full configuration it prints. Please mention your node and npm version and operating system.Thanks!
The text was updated successfully, but these errors were encountered: