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

Optimizing Image Handling in Swift Snapshot Testing #828

Open
Life-run9723 opened this issue Jan 26, 2024 · 0 comments
Open

Optimizing Image Handling in Swift Snapshot Testing #828

Life-run9723 opened this issue Jan 26, 2024 · 0 comments

Comments

@Life-run9723
Copy link

Hi,
I am using this awesome library for snapshot testing in an iOS project and facing a couple of challenges related to image management and comparison.

Managing Baseline and New Failed Images:
In my snapshot tests, I initially set isRecording to true to capture the baseline image. For example:

func testExampleSnapshot() {
    let view = CustomView(viewModel: .fixture()).background(Color.white)
    let controller = UIHostingController(rootView: view)
    controller.view.backgroundColor = .systemYellow

    isRecording = true
    SnapshotTesting.diffTool = "ksdiff"
    assertSnapshot(matching: controller, as: .image)
}

This works well for creating the baseline image. However, when a change in the view causes the snapshot test to fail, the newly generated failed image is saved in a different location from the baseline image. This necessitates a manual search to find and compare the new failed image, which is quite time-consuming.

Is there a more streamlined process for this? Ideally, I'd like the new failed image to be automatically saved in the same folder as the baseline image. This would allow for easier comparison using tools like SourceTree, without the need to toggle isRecording between true and false for updating the baseline. Any suggestions for a more efficient approach would be greatly appreciated.

Organizing Snapshot Images:
Currently, the baseline images are stored in multiple folders within the snapshot folder, corresponding to each test file. This results in numerous directories containing these images.

Is there a more organized way to handle this? Perhaps storing all images in a single folder, categorized by test class name or function, might be more manageable. I'm seeking advice on the best practices for efficiently organizing these snapshot images in a professional setup.

Any insights or suggestions on these issues would be greatly appreciated!

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

1 participant