Skip to content

Feature request: inline snapshots #6

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

Closed
matklad opened this issue Jan 23, 2019 · 3 comments
Closed

Feature request: inline snapshots #6

matklad opened this issue Jan 23, 2019 · 3 comments

Comments

@matklad
Copy link
Contributor

matklad commented Jan 23, 2019

Currently snapshots are stored in a separate files which is super-convenient for updating them, but makes reading the tests more difficult, because you don't have a test code and tests result near each other.

One could imagine a three argument form of assert_debug_snaphot_mathes, where the third argument is the text of the snapshot. It seems like this won't work, because updating the snapshot will require updating the source code, but perhaps it is possible? Snapshots have a well-defined header, so just grepping src for them should perhaps work? This sounds like a terrible idea, but I can see myself using it :)

@max-sixty
Copy link
Collaborator

This is similar to expect tests in OCaml.

I made an attempt at this (before this library) to do this by using the file!-like macros and reading up the traceback but I found it difficult. I'd be up for making another go with some direction from someone who knows the language better

@mitsuhiko
Copy link
Owner

Yap, this is happening. I already started work on this but I first need to get some changes landed in proc-macro2: dtolnay/proc-macro2#165

@mitsuhiko
Copy link
Owner

This is implemented now on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants