Skip to content

Instantly share code, notes, and snippets.

@bannzai
Created October 24, 2025 00:47
Show Gist options
  • Select an option

  • Save bannzai/b2b8b5e8a284115af1e568b492899302 to your computer and use it in GitHub Desktop.

Select an option

Save bannzai/b2b8b5e8a284115af1e568b492899302 to your computer and use it in GitHub Desktop.
import XCTest
import SwiftUI
final class RetryPageSnapshotUITest: XCTestCase {
override class var runsForEachTargetApplicationUIConfiguration: Bool {
false
}
override func setUpWithError() throws {
continueAfterFailure = false
}
let previewType = "RetryPage_Previews"
let previewCount = 1
func testSnapshot() throws {
XCUIDevice.shared.appearance = .dark
let fileName = URL(fileURLWithPath: #file).deletingPathExtension().lastPathComponent
let functionName = #function.replacingOccurrences(of: "()", with: "")
filteredLanguages().forEach { (language, languageWithRegion) in
debugPrint("Start: ", #file, #function, language)
let app = XCUIApplication.instantiate()
app.launchArguments += ["-AppleLanguages", "(\(language))"]
app.launch()
for index in (0..<previewCount) {
app.buttons["\(previewType)_\(index)"].firstMatch.tap()
sleep(1)
let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "\(fileName)---\(functionName)---\(language)---\(index)"
attachment.lifetime = .keepAlways
add(attachment)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment