Add previews reference document#61
Conversation
…terns The skill currently has no coverage for testing or previews. Add a new reference covering #Preview macro usage and traits, @Previewable for inline bindings, mock data patterns for previews, XCTest strategies for @observable models and UI tests, ViewInspector for view-layer unit testing, and snapshot testing with swift-snapshot-testing.
There was a problem hiding this comment.
Pull request overview
This PR adds a new on-demand reference for SwiftUI testing and preview workflows, then wires that reference into the skill so agents can discover it through the topic router and references list. It expands the skill’s coverage around previews, mock data, model testing, UI tests, and snapshot testing.
Changes:
- Add
references/testing-previews.mdwith guidance for#Preview,@Previewable, mock preview data, XCTest/XCUITest patterns, and snapshot testing. - Register the new testing/previews reference in the SKILL topic router and reference list.
- Extend the SKILL correctness checklist with a preview-specific rule about using self-contained mock data instead of live services.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
swiftui-expert-skill/references/testing-previews.md |
New reference document covering preview setup, mock data patterns, testing approaches, diagnostics, and checklist guidance. |
swiftui-expert-skill/SKILL.md |
Adds the new reference to discovery points and updates the correctness checklist with a preview-data rule. |
Per AGENTS.md, testing frameworks and patterns are excluded from this skill. Drop the XCTest, XCUITest, snapshot testing, and @observable model testing sections, and rename the reference to previews.md so the file name matches its remaining scope. Also addresses the Copilot review: - Remove the UIKit/AppKit preview section (off-mission per the SwiftUI-first operating rule). - Replace the invented URLSession.decode(_:from:) call with a real URLSession.data(from:) + JSONDecoder pair. - Switch the @Previewable @focusstate example from .onAppear writes to .defaultFocus, matching focus-patterns.md. - Soften the "use #Preview for all new previews" checklist item to a preference, since PreviewProvider is not deprecated. - Cross-link state-management.md and focus-patterns.md from the preview docs. - Restore the blank line between the correctness checklist and the References section in SKILL.md.
|
Hi @jack-old-archive — since this PR has been waiting on review feedback for a while, I've pushed a commit to your branch (the Scope reductionPer
The correctness checklist item about preview mock data is kept — that's a correctness concern (previews must compile and render without external dependencies) and fits the skill's scope. Resolution of Copilot's review comments
Additional fixes I noticed
What stayed
Thanks for the contribution — the previews material is genuinely useful and worth keeping. Please shout if you'd like to revisit any of the removed testing content as a separate, scoped contribution to a different repository (or a focused follow-up if we ever expand the skill's scope). |
Summary
references/previews.mdcovering SwiftUI preview patterns#Previewmacro usage, preview traits,@Previewablefor inline interactive state (iOS 18+), and mock data patterns for self-contained previewsSKILL.mdto register the new reference in the topic router and reference listNotes
This started as a broader testing-and-previews contribution, but per
AGENTS.mdtesting frameworks and patterns are explicitly out of scope for this skill, so the testing sections were dropped and the file was renamed fromtesting-previews.mdtopreviews.md. See the discussion thread for details.