swift-snapshot-testing
swift-snapshot-testing copied to clipboard
Circle color not showing in Snapshot after updating the progress value on .onAppear SwiftUI
I am animating circle and OnAppear block I am updating the current progress of the circle
public struct CountdownProgressCircle: View {
@Binding public var progress: TimeInterval
public var body: some View {
Circle()
.trim(from: 0.0, to: CGFloat(min(progress, 1.0)))
.foregroundColor(Color.green)
.rotationEffect(Angle(degrees: 270.0))
.animation(.linear)
}
}
.onAppear(perform: {
currentProgress = state.currentProgress
})
I am using wait of 5 seconds
assertSnapshot(matching: view, as: .wait(for: 5.0, on: .image), named: "Setup")
My Swift previous shows me below view
Snapshot output:
The output should be exactly the same as swiftUI preview but I think there is an issue while taking a snapshot
I am going through a similar issue:
I am having a view which uses a custom of the .redacted() feature to show loading placeholders, and for the animation I trigger onAppear the boolean state to be set to true. On preview and when running it works just well, but the snapshot tests are not detecting such bool update.
I have the impression that when running the tests we need to force onAppear to be run, so our values update and our views change accordingly. Anyone could help us here?