-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Improve snapshot diff display #36
Comments
Hi 👋 Do you have an idea about what you're expecting? ^^ I think the entry point is here ? https://github.com/antfu-sponsors/vitest/blob/4742d44466bafea5253eaf744fe4721ca1620e43/src/integrations/chai/snapshot/utils/jest-reporters-lite.ts#L35 |
Yes. That snapshot folder is basically a port of https://github.com/mochiya98/mocha-chai-jest-snapshot, and we will need to rewrite the printing to use our reporter interface and match with the overall CUI design. Currently, I see the improvement is to make the diff of large objects or long strings easier to read. Thanks for interesting in it btw! |
You're welcome. I'd like to give it a try on this. If it's okay for you^^ |
I looked a bit at the code and seems that what we want to improve is there: https://github.com/antfu-sponsors/vitest/blob/main/src/integrations/snapshot/client.ts#L68-L74 The
I think that If we want to provide a different experience we should implement:
This approach seems ok for you?
|
We already have the diff here: So maybe we could have some thing to mark the snapshot check in the error and let the main thread do some conditional formating |
Hey 👋 Thanks for merging the quick refactor ^^ I think that the incremental approach it's the better one. Now I have a better vision about where I should play: What I have imagined in terms of improvement is: Display the object with (image it will more color than that ^^ and more polished): 👋🏼 Hey hacker: we found a diff between what is expected and what is actual:
1 - Where:
Object {
"this": Object {
"is": Set {
-> 🙈 Here (Something goes wrong at this position)
"snapshot",
},
},
}
2 - What we got:
-> "of",
3 - What we want:
-> "hey"
Then, If objects/strings become very long we have them isolated. Let me know. I prefer to ask first, to be sure that on your side you agree with this approach. If you don't like it, I can imagine something else. |
I would like to have this minimal as possible. As we might expect multiple snapshot reporting in the same run, making it short could make improve the readability. I think we could:
|
Here a diff between a string and a big array (length: 300) What do you think @antfu? |
Looks good |
No description provided.
The text was updated successfully, but these errors were encountered: