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

experimenting with inline snapshot support #70

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gkampitakis
Copy link
Owner

@gkampitakis gkampitakis commented Jul 8, 2023

The api right now looks like

Calling the first time

t.Run("my test", func(t *testing.T) {
user := struct{ Name string }{
	Name: "george",
}

snaps.MatchInlineSnapshot(t, user, nil)
})

and then it will populate with the snapshot data

t.Run("my test", func(t *testing.T) {
user := struct{ Name string }{
	Name: "george",
}

snaps.MatchInlineSnapshot(t, user, snaps.Inline("struct { Name string }{Name:\"george\"}"))
})

Still haven't investigated all the edge cases that this can have and I can see being useful but not sure how much is it worth it.

Two issues that are not addressed

  • Long line snapshots, haven't found a way to split text to multiples lines
    - I believe jest doesn't address it at all. I want to also have a look how it's handled by insta.
  • Comments ast parsing.
    - I have seen some weird behaviours, but nothing major. I want to test further.
  • Currently there is an issue with the current approach. If a file has multiple InlineSnapshots and updated at the same time the file lines can be moved breaking the "write". I am investigating ways to fix this.
  • I want to run tests to make concurrent (t.Parallel) safe.

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

Successfully merging this pull request may close these issues.

1 participant