swift-snapshot-testing-macros

2.0.2

A Swift Macro library for generating snapshot tests from functions
adammcarter/swift-snapshot-testing-macros

What's New

2.0.2

2026-03-19T17:11:22Z

📎 Updated to use v1.19.1 of swift-snapshot-testing which adds support for attachments when using Swift Testing

What's Changed

Full Changelog: 2.0.1...2.0.2

Snapshot Tests

Overview

SnapshotTestingMacros is a thin layer over swift-testing and swift-snapshot-testing to allow for macro based snapshots using a syntax similar to Swift Testing.

Just as Swift Testing has @Suite and @Test, SnapshotTestingMacros uses @SnapshotSuite and @SnapshotTest to mark up code.

This allows for snapshots to quickly be created by simply marking up functions that return views.

Example code

In the simplest case this is all that's needed for a snapshot test:

// ✅ Create a simple snapshot test for some SwiftUI text.

@Suite
@SnapshotSuite
struct MySnapshots {

  @SnapshotTest
  func myView() -> some View {
    Text("Some text")
  }
}

Note that while @Suite isn't explicitly needed to run the snapshots, it's currently recommneded so Xcode can pickup the generated Suite inside the macro. Due to macro limitations it seems that Xcode cannot see Suites when they're embedded inside macro expansion code.

Documentation

  • Usage - Basic usage, example code, and async support.
  • Traits - Customising snapshots with traits (sizes, themes, padding, etc.).
  • Parameterised Tests - Creating snapshots for multiple configurations.

Supported views

  • SwiftUI: Any view conforming to View
  • UIKit (iOS, tvOS, visionOS): UIView, UIViewController
  • AppKit (macOS): NSView, NSViewController

Running tests

For detailed instructions on running tests, please see CONTRIBUTING.md.

Contributing

This project uses mise to manage development tools.

See CONTRIBUTING.md for detailed setup and guidelines.

Description

  • Swift Tools 6.2.0
View More Packages from this Author

Dependencies

Last updated: Tue Mar 31 2026 19:03:51 GMT-0900 (Hawaii-Aleutian Daylight Time)