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

Add functionality for Expect Testing #825

Open
harryjulian opened this issue Oct 23, 2023 · 3 comments
Open

Add functionality for Expect Testing #825

harryjulian opened this issue Oct 23, 2023 · 3 comments
Labels
community Discussions or community related feature request New feature or request

Comments

@harryjulian
Copy link

harryjulian commented Oct 23, 2023

Is your feature request related to a problem? Please describe.

I like using syrupy for snapshot testing across my projects, but I'd be interested in expect testing, which is outlined in this article on the Jane Street tech blog.

The main difference between regular snapshot testing and expect testing is the interactive component - the developer is shown either the test result, or a diff, in the console and can save the result with a keybinding if they deem the result correct and appropriate.

Sometimes when I'm using snapshot testing I'd like to actually know what snapshots look like to quickly manually verify them. I also imagine this could be useful for a sort of TDD utilising snapshotting, where you write your tests a priori and then iterably verify the outputs until they're correct.

Describe the solution you'd like

I'd like to implement a means of conducting expect testing in syrupy. This just means expanding the framework to, if expect testing is somehow toggled, add an additional step at the end of testing where the user is presented with an interactive console session to accept/reject test outputs if there are either diffs or not results.

To keep this sort of testing as a separate entity, I'd probably think about implementing a new fixture - expect - through which to manage the process. I'd give more thought to the implementation if the feature is of interest. If so, I'd be happy to collaboratively work on implementing it.

@noahnu
Copy link
Collaborator

noahnu commented Oct 24, 2023

This is an interesting idea. Have you seen another pytest plugin that adds some interactivity?

@noahnu noahnu added feature request New feature or request community Discussions or community related labels Oct 24, 2023
@harryjulian
Copy link
Author

harryjulian commented Oct 24, 2023

I've not used any plugins that use interactivity before, but I've made a simple plugin here that adds a very basic/ugly version of the post-test accept/reject functionality.

@thijsmie
Copy link

I'd also be interested in this, since right now I'm effectively running the whole testsuite twice in different modi, once to get the failures, then inspecting the failures whether the update is correct and then with snapshot-update. Since I have all check tools wrapped up in a makefile of sorts I would love to run make all --fix which allows me to interactively update the snapshots and then in CI make all which rejects updates as normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Discussions or community related feature request New feature or request
Projects
Status: No status
Development

No branches or pull requests

3 participants