swift-snapshot-testing-macros

3.0.0

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

What's New

3.0.0

2026-04-09T13:57:15Z

📁 Snapshot configurations are now grouped by test instead of configuration*

*If you use snapshot configurations you will have to regenerate snapshot images - no images should change, only their folder/file name structure.


What's Changed

Full Changelog: 2.0.2...3.0.0

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: Sun Apr 19 2026 07:46:55 GMT-0900 (Hawaii-Aleutian Daylight Time)