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

Wait before capturing a snapshot #28

Open
sparafinski opened this issue Nov 22, 2023 · 3 comments
Open

Wait before capturing a snapshot #28

sparafinski opened this issue Nov 22, 2023 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@sparafinski
Copy link

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

While attempting to capture a view that includes AsyncImage or revealing a component after a specified duration, it's been noticed that the resulting snapshot doesn't include images loaded via URL or views that appear with a slight delay. Even when using .snapshot(delay: 1.0), there's no noticeable improvement in this scenario.

What 🌱

To overcome this challenge, it would be helpful to incorporate an option to wait before taking the snapshot. This way, we can ensure that the snapshot accounts for the asynchronous loading of images and views that emerge after a delay.

Example of a view that isn't properly captured in the snapshot:

struct DummyView: View {
    @State var isButtonHidden = true
    var body: some View {
        VStack {
            Text("Some text")
            Text("Some text with delay")
                .opacity(isButtonHidden ? 0 : 1)

        }.onAppear {
            DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                self.isButtonHidden = false
            }
        }
    }
}
@sparafinski sparafinski changed the title Way to wait for view to fully load Wait before capturing a snapshot Nov 22, 2023
@BarredEwe
Copy link
Owner

It seems that this is a problem of the swift-snapshot-tests library. I found a PR in it that should fix this.

I'll try to think later about how to get around this inside the Prefire.

@sparafinski
Copy link
Author

Also, it seems that .preferredColorScheme(.dark) is not handled properly. I found a PR that states it should already work πŸ€” using swift-snapshot-tests . Do you think it could be the same cause?

@BarredEwe
Copy link
Owner

It sounds like a bug in the Prefire. I set myself the task to fix it in the 2.0 release 😊

@BarredEwe BarredEwe added the bug Something isn't working label Jan 23, 2024
@BarredEwe BarredEwe added the good first issue Good for newcomers label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants