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

Snapshots names doesn't contain view name #80

Open
AllDmeat opened this issue Dec 5, 2024 · 1 comment
Open

Snapshots names doesn't contain view name #80

AllDmeat opened this issue Dec 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@AllDmeat
Copy link

AllDmeat commented Dec 5, 2024

Context πŸ•΅οΈβ€β™€οΈ

We've been using swift-snapshot-testing for quite a while, but without Prefire. swift-snapshot-testing saved snapshots with for each view into separate folder:

ModuleName
└── Tests
    └── __Snapshots__
        β”œβ”€β”€ AuthViewTests
        β”‚   β”œβ”€β”€ newUser.png
        β”‚   └── existingUser.png
        └── CartViewTests
            β”œβ”€β”€ emptyState.png
            └── errorState.png

What 🌱

Prefire saves all snapshots into single same folder, so resulting structure is like this:

ModuleName
  ModuleNameTests
    __Snapshots__
      PreviewTests
        newUser.png
        existingUser.png
        emptyState.png
        errorState.png

We are using #Preview to specify name of a preview/snapshot like this:

#Preview("newUser") {
    // my preview
}

This may lead to names being overlapped between multiple views and it actually already did happen in our project.
To avoid this we duplicate our view name into preview name like this:

#Preview("AuthView newUser") {
    // my preview
}

That solves the issue, but creates unnecessary duplications of a view name in canvas previews.

Proposal πŸŽ‰

I believe saving snapshot into folder named after source file name #Preview originated from can solve this issue:

ModuleName
└── ModuleNameTests
    └── __Snapshots__
        β”œβ”€β”€ AuthViewTests
        β”‚   β”œβ”€β”€ newUser.png
        β”‚   └── existingUser.png
        └── CartViewTests
            β”œβ”€β”€ emptyState.png
            └── errorState.png
@BarredEwe
Copy link
Owner

Hi! I like this change. It doesn't look complicated. I'll try to make it in the next release!

@BarredEwe BarredEwe added the enhancement New feature or request label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants