-
Notifications
You must be signed in to change notification settings - Fork 308
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
Different snapshot with --coverage #220
Comments
It is probably on our side, I guess it results from the combination of the Serializer and the modified html stringification of ts-jest 23.10. Can you post your (minimal) component and your test? This would simplify the process for us to look into it. |
I finally managed to reproduce this.
It happens when the template renders some function, e.g. when used as an input to some child component. The function itself must be in different file, otherwise there is no difference. Now when i prepared the simple test case i can see that in it is the same problem with Istanbul as here. |
Thank you for the reproduction! It seems that if runnable code is imported and injected into templates in this way, we have to filter out the istanbul coverage tags manually. Which might become a mess. |
Jest should replace functions with a I'd say this is not something you'd like to snapshot, and I don't think there's really anything from this preset nor Jest's side that we can do that makes sense. Feel free to write a small serializer that replaces istanbul comments with some token or anything that doesn't change. Closing, I hope you understand. |
@thymikee this was just simplest example i could think of. In my real setup i don't serialize the function to html directly, but it is an
Current behaviour doesn't allow to snapshot test a component which uses some other component with function I'll try to write the serializer and see how far i can get ;) |
So i was forced to finally write the serializer as our CI rendered functions differently than local machine and not only for coverage. Whole problem is that Angular serializes function inputs in such way that it takes the implementations first N characters and writes them into the DOM. So it renders something like this:
I wrote a serializer that checks whether such attribute exists and just replaces it with
|
@ahnpnl it's released in 7.1.0, needs to be added manually though (there are docs on that) |
@Ludevik I updated changelog for 7.1.0, you can try the new serializer 👍 |
Cool, if only i've reread the readme after release i could spare myself from reinventing the wheel, but at least i got some insights how serializers work in jest :) |
@Ludevik always learning, that's the attitude! I could've at least pushed the tag but forgot about it as I made a release during my time off 😅 |
I am currently using [email protected] and our CI builds started to failing due to different snapshot when using jest with
--coverage
:This started to happend when I upgraded to version 7 which uses ts-jest. Not sure who is responsible for serializing components. There is similar issue, but I don't see anything related to istanbul in my snapshot.
The text was updated successfully, but these errors were encountered: