一键导入
snapshot
Creates Snapshot Tests for SwiftUI Views using ChallengeSnapshotTestKit. Use when creating visual regression tests for views with DSAsyncImage support.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Creates Snapshot Tests for SwiftUI Views using ChallengeSnapshotTestKit. Use when creating visual regression tests for views with DSAsyncImage support.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Swift 6 concurrency patterns. Use when working with async/await, actors, MainActor isolation, or Sendable conformance.
Creates Features for dependency injection. Use when creating features, exposing public entry points, or wiring up dependencies.
Creates Repositories that abstract data access. Use when creating repositories, transforming DTOs to domain models, or implementing local-first caching. Supports remote-only, local-only, and cached (remote + local) repositories with CachePolicy.
Creates a new feature module with minimal viable structure. Use when bootstrapping a new feature from scratch, scaffolding the Tuist module, Container, Feature entry point, DeepLinkHandler, and initial screen with placeholder Text view. Includes all unit tests, mocks, stubs, and app integration. For adding domain/data layers afterward, use /datasource, /repository, /usecase. For enhancing views, use /view, /viewmodel, /navigator.
Creates Navigator for navigation. Use when setting up navigation, adding navigation to ViewModels, or testing navigation behavior.
Creates ViewModels with state management. Use when creating ViewModels, implementing ViewState pattern, or adding state management for features. Delegates to /usecase for domain use cases and to /feature for Container/Feature wiring.
| name | snapshot |
| description | Creates Snapshot Tests for SwiftUI Views using ChallengeSnapshotTestKit. Use when creating visual regression tests for views with DSAsyncImage support. |
Guide for creating Snapshot Tests using ChallengeSnapshotTestKit. Tests only use ChallengeSnapshotTestKit's public API. See the module README for internal details.
ChallengeSnapshotTestKit dependency in snapshot test targets (added automatically by Tuist)DSAsyncImage component (replaces AsyncImage)ImageLoaderMock in CoreMocksTests/Shared/Resources/Tests/
├── Snapshots/
│ └── Presentation/
│ └── {Name}/
│ ├── {Name}ViewSnapshotTests.swift
│ └── __Snapshots__/
└── Shared/
├── Stubs/
│ └── {Name}ViewModelStub.swift
└── Resources/
└── test-avatar.jpg
Uses instance variables pattern for cleaner tests:
struct {Name}ViewSnapshotTests {
// MARK: - Properties
private let imageLoader: ImageLoaderMock
// MARK: - Initialization
init() {
UIView.setAnimationsEnabled(false)
imageLoader = ImageLoaderMock(cachedImage: .stub, asyncImage: .stub)
}
// MARK: - Tests
@Test("Renders loading state correctly")
func loadingState() {
// Given
let viewModel = {Name}ViewModelStub(state: .loading)
// When
let view = NavigationStack {
{Name}View(viewModel: viewModel)
}
.imageLoader(imageLoader)
// Then
assertSnapshot(of: view, as: .device)
}
}
UIView.setAnimationsEnabled(false)ImageLoaderMock with test image.imageLoader(imageLoader) on viewNavigationStack.device strategy for full-screen views, .image for components, .component(size:) for components that wrap a ButtonimageLoader modifier{Name}ViewSnapshotTests.swift{stateName}State() (e.g., loadingState)@Test("Renders {state} state correctly")__Snapshots__/{Name}ViewSnapshotTests/xcodebuild test \
-workspace Challenge.xcworkspace \
-scheme "Challenge (Dev)" \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro,OS=26.1'
First run creates references and fails (expected).
Re-run the same command. Snapshots now compare against recorded references.
rm -rf Tests/Snapshots/Presentation/{Name}/__Snapshots__
# Run twice: first creates references, second verifies
ChallengeSnapshotTestKit is automatically included by Tuist in snapshot test targetsTests/Shared/Resources/Tests/Shared/Stubs/DSAsyncImage in ViewTests/Snapshots/@Test attributes include a descriptionImageLoaderMock.device strategy for full-screen views