-
Notifications
You must be signed in to change notification settings - Fork 642
Open
Description
Describe the bug
Snapshot tests produce transparent images when a NavigationStack toolbar contains a button with .buttonStyle(.borderedProminent). The same view renders correctly in Xcode Previews and the actual app.
To Reproduce
import SnapshotTesting
import SwiftUI
import Testing
@MainActor
@Suite
struct MinimalReproductionTest {
@Test func toolbarWithBorderedProminentButton() {
struct TestView: View {
var body: some View {
NavigationStack {
Text("Content")
.navigationTitle("Test")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Save") {}
.buttonStyle(.borderedProminent)
}
}
}
}
}
assertSnapshot(of: TestView(), as: .image(layout: .device(config: .iPhone13Pro)))
}
}Expected behavior
The snapshot should capture the toolbar with the bordered prominent button visible, matching the appearance in Xcode Preview and the actual app.
Screenshots
The generated snapshot image has correct dimensions (1170x2532) but is completely transparent.
Environment
- swift-snapshot-testing version: 1.18.7
- Xcode: 26.1.1 (17B100)
- Swift: 6.2.1
- OS: iOS
Additional context
Works correctly:
.borderedProminentbutton outside of toolbar- Plain button inside toolbar (without
.buttonStyle(.borderedProminent))
Fails (transparent):
.borderedProminentbutton inside toolbar
The issue is specific to the combination of NavigationStack toolbar + .borderedProminent button style in snapshot tests.
Metadata
Metadata
Assignees
Labels
No labels