with one click
snapshot
// Use swift-snapshot-testing to visually verify SwiftUI views during implementation. Renders views to PNG for comparison against design references. Fast feedback loop (~25s/cycle).
// Use swift-snapshot-testing to visually verify SwiftUI views during implementation. Renders views to PNG for comparison against design references. Fast feedback loop (~25s/cycle).
Evaluate WooAIAssistant against a structured scenario suite with hard invariants + LLM-as-judge rubric scoring. Runs live against the demo store + gpt-5.1 via the woo-mobile-ai backend wrapper, writes a JSONL run record, compares against stored baselines, and surfaces regressions. Always delegated to a subagent so the main context only sees the markdown report.
Create a pull request following WooCommerce iOS conventions
Set up the ContextA8C MCP server for accessing Automattic internal resources (Slack, Linear, P2s, GitHub Enterprise, etc.)
Discover and boot an iOS simulator. Use before any command that needs a simulator UDID.
Build the app, launch on simulator, and verify feature behavior via mobile-mcp interaction. Use after making changes to visually confirm they work from a user's perspective.
Start or stop the WireMock API mock server for UI testing and E2E verification.
| name | snapshot |
| description | Use swift-snapshot-testing to visually verify SwiftUI views during implementation. Renders views to PNG for comparison against design references. Fast feedback loop (~25s/cycle). |
| user-invocable | true |
| allowed-tools | Bash, Read, Write, Edit, Grep, Glob |
| argument-hint | [view-name or test-target] |
Use swift-snapshot-testing to create a visual feedback loop when implementing UI changes. Render SwiftUI views to PNG after each code change, compare against design goals, fix mismatches, and repeat.
1. SETUP Add swift-snapshot-testing dependency (temporary)
2. GOAL Collect design reference images
3. SCAFFOLD Create snapshot test rendering the target view
4. LOOP For each implementation step:
a. Edit code
b. Run snapshot test (record mode)
c. Read generated PNG
d. Compare against design
e. If mismatch -> fix and re-snapshot
f. If match -> commit the verified change, move to next step
5. CLEANUP Revert dependency + delete test file
Check if swift-snapshot-testing already exists in Modules/Package.swift. If not, add it temporarily.
In the dependencies array of Modules/Package.swift:
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.17.0"),
In the relevant test target's dependencies array:
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
Common test targets in this project:
PointOfSaleTests — for POS viewsWooFoundationTests — for shared UI componentsYosemiteTests — for business logic viewsRemember the original state of Modules/Package.swift so you can revert exactly after cleanup.
If the user provides design reference images (Figma exports, screenshots):
mkdir -p ~/Downloads/snapshot_experiment
cp ~/path/to/design.png ~/Downloads/snapshot_experiment/design.png
Read each reference image to understand the target state before writing code.
If no reference image, the goal is inferred from the user's description of desired UI behavior.
Create a test file in the appropriate Modules/Tests/*Tests/ directory:
import XCTest
import SnapshotTesting
import SwiftUI
@testable import TargetModule
final class ViewNameSnapshotTests: XCTestCase {
override func invokeTest() {
withSnapshotTesting(record: .all) {
super.invokeTest()
}
}
func test_defaultState_snapshot() {
let view = YourView(/* props for default state */)
.frame(width: 375, height: 900)
assertSnapshot(of: view, as: .image(layout: .sizeThatFits))
}
func test_alternateState_snapshot() {
let view = YourView(/* props for alternate state */)
.frame(width: 375, height: 900)
assertSnapshot(of: view, as: .image(layout: .sizeThatFits))
}
}
Important details for this project:
record: .all in invokeTest() forces PNG generation every run.environment(\.horizontalSizeClass, .regular) — POS is iPad-first.frame(width:height:) to control render size. Start with height: 900, increase to 1200+ if content is clippedPOSPadding, POSSpacing, POSFontStyle, Color+POSColorPalette) when comparing POS designsUse the /simulator skill approach to discover a booted simulator UDID.
Run only the snapshot tests for fast feedback:
xcodebuild test \
-workspace WooCommerce.xcworkspace \
-scheme WooCommerce \
-destination 'platform=iOS Simulator,id=<SIMULATOR_UDID>' \
-only-testing:<TestTarget>/<SnapshotTestClass> \
CODE_SIGNING_ALLOWED=NO 2>&1 | tail -30
Prefer module-level test targets over the full app for faster feedback (~25s vs minutes).
Generated PNGs appear at:
Modules/Tests/<TestTarget>/__Snapshots__/<TestClass>/test_name.1.png
After each run:
cp Modules/Tests/<Target>/__Snapshots__/<Class>/test_name.1.png ~/Downloads/snapshot_experiment/step1.png
Common issues caught by snapshots:
.lineLimit(1).fixedSize(horizontal: true, vertical: false), reduce padding.environment(\.horizontalSizeClass, .regular)POSPadding/POSSpacing values against designWhen fixing: edit the code and re-run snapshots to verify. Only commit once the snapshot matches the design goal — don't commit untested changes.
After implementation is complete, revert ALL temporary changes:
# Revert Package.swift (removes snapshot dependency)
git checkout -- Modules/Package.swift
# Revert Package.resolved if it changed
git checkout -- Modules/Package.resolved
# Also revert workspace Package.resolved if changed
git checkout -- WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved
# Delete the snapshot test file
rm Modules/Tests/<TestTarget>/<SnapshotTestClass>.swift
# Delete generated snapshot directory
rm -rf Modules/Tests/<TestTarget>/__Snapshots__
# Verify clean state
git status
Critical: Never commit snapshot test files, __Snapshots__/ directories, or the swift-snapshot-testing dependency. These are temporary iteration tools only.
| Action | Command/Tool |
|---|---|
| Add dependency | Edit Modules/Package.swift |
| Run snapshots | xcodebuild test -only-testing:<Target>/<Class> |
| Find PNGs | Modules/Tests/<Target>/__Snapshots__/<Class>/test_name.1.png |
| View snapshot | Read tool on the PNG path |
| Compare | Read both snapshot PNG and design reference |
| Fix + re-run | Edit code, re-run xcodebuild, commit once verified |
| Clean up | git checkout -- Modules/Package.swift, rm test file + snapshots |