- Home
- Skills
- Rshankras
- Claude Code Apple Skills
- Snapshot Test Setup
snapshot-test-setup_skill
- Swift
56
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
3 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill rshankras/claude-code-apple-skills --skill snapshot-test-setup- SKILL.md9.0 KB
Overview
This skill sets up SwiftUI visual regression (snapshot) testing using Point-Free’s swift-snapshot-testing. It generates test boilerplate, configures device and color-scheme matrices, and adds CI steps to run and surface snapshot failures. Use it to prevent unintended UI changes and keep visual regressions visible in CI.
How this skill works
The skill adds the SnapshotTesting dependency to your test target (SPM, CocoaPods, or Tuist), creates reusable snapshot configuration and test suites for views and components, and scaffolds recording and re-recording flows. It also generates CI steps to run tests on simulators and upload failure artifacts so diffs are accessible when tests fail.
When to use it
- You want screenshot or visual regression tests for SwiftUI views.
- You need to prevent accidental UI changes reaching main branches.
- You use or plan to use Point‑Free’s swift-snapshot-testing library.
- You want CI to fail and show visual diffs for UI regressions.
- You need reproducible snapshots across device sizes, color schemes, and dynamic type.
Best practices
- Snapshot high-value screens and reusable components (empty, loaded, error states).
- Test both light and dark color schemes and at least one accessibility size for dynamic type.
- Record reference images once locally, commit __Snapshots__ directories to source control.
- Keep low-value or rapidly changing views out of snapshot suites to reduce noise.
- Add CI step to run snapshots on a stable simulator and upload failed-snapshot artifacts for review.
Example use cases
- Generate HomeView snapshot suite: light, dark, empty, and large dynamic type tests.
- Create component snapshots for ItemCard: default, selected, and long-title wrapping.
- Add macOS window-size snapshots for SettingsView with light and dark mode variants.
- Configure GitHub Actions to run snapshot tests and upload failed images for PR review.
- Temporarily enable record mode (env var or test wrapper) to re-record golden images after intentional UI updates.
FAQ
Run tests locally with xcodebuild test targeting a simulator. The first run records reference images into __Snapshots__ folders next to the test files—commit those to git.
How do I update snapshots when a change is intentional?
Run tests in record mode (set SNAPSHOT_TESTING_RECORD=all or use the provided record wrapper in the test) to overwrite reference images, then verify and commit the new snapshots.