-
-
Notifications
You must be signed in to change notification settings - Fork 573
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
Add snapshot test using insta #2411
base: master
Are you sure you want to change the base?
Conversation
@extrawurst I just marked this PR as ready for review! I found it way easier to create the test than I had anticipated, mostly because the application is already structured in a way that is very amenable to snapshot testing. Known issues:
|
@extrawurst Did you get a chance to have a look? 😄 |
@cruessler ok i think this is a great prototype but i don't think its ready to be merged in this form.
|
@extrawurst I’ve extracted app initialization as well as the main loop into a new struct, I’m not sure about how to best implement a busy loop, though. We might be able to send the event that we get here, through a channel to the caller. Then, we could, in the caller, have a |
@cruessler awesome!
yeah lets do that. |
This will hopefully make the test green on CI.
This will hopefully make the test green on CI.
@extrawurst Just a little status update: I think I’ll get to this PR this week. |
@extrawurst It turned out that removing What do you think? |
@cruessler i love it! is there a way to control the size of the test buffer? I would prefer to have tests only use the minimum required buffer size for the purpose of the test to still make sense |
Do you mean the size of the test terminal? Yes, that is completely configurable. https://github.com/cruessler/gitui/blob/b1ce826faf455239df610a1a68e7ab090cd4fec4/src/gitui.rs#L241 If you want to find a good size yourself, feel free to add a commit to this PR. Instructions for running One thing I forgot to mention: the busy loop in |
@extrawurst This PR is another try at adding snapshot tests to
gitui
. It doesn’t render to SVG as some of the other approaches do, but it works with the existingApp
anddraw
and only requires a minor type change in order to get it to work. Also, the text-based snapshot is still reasonably easy to read. So this feels very promising.Next, I want to try to write a test that has interactivity, be it loading data from an actual git repo or keyboard input from a user.