Skip to content

.borderedProminent button in Toolbar renders as transparent image in snapshot tests #1038

@mnaruse

Description

@mnaruse

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:

  • .borderedProminent button outside of toolbar
  • Plain button inside toolbar (without .buttonStyle(.borderedProminent))

Fails (transparent):

  • .borderedProminent button inside toolbar

The issue is specific to the combination of NavigationStack toolbar + .borderedProminent button style in snapshot tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions