Fix deprecated verifySnapshot(record:) in generated tests#165
Merged
BarredEwe merged 1 commit intoJul 8, 2026
Merged
Conversation
The generated PreviewTests called verifySnapshot/assertSnapshot with the Bool 'record' overload, deprecated in swift-snapshot-testing 1.15+ in favor of 'record: SnapshotTestingConfiguration.Record?'. In projects building tests with warnings-as-errors this fails the build. Map the Bool to Record the same way swift-snapshot-testing's own compatibility shim does: true -> .all, false -> .missing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The generated
PreviewTestscallverifySnapshot(andassertSnapshotfor AccessibilitySnapshot) with theBoolrecord:overload, which swift-snapshot-testing deprecated in 1.15+ in favor ofrecord: SnapshotTestingConfiguration.Record?.In projects that build their test target with warnings-as-errors (
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES), the generated file fails to compile:Since the generated file is regenerated on every build, consumers cannot edit it, so the only way to keep warnings-as-errors is to fix the template.
Change
In
PreviewTestsTemplate.swift, map theBoolpreference toRecordexactly the way swift-snapshot-testing's own compatibility shim does (Deprecations.swift):So
record: preferences.recordbecomesrecord: preferences.record ? .all : .missingin both theverifySnapshotand theassertSnapshotcalls. Behavior is preserved.Notes
.all/.missingexist since swift-snapshot-testing 1.15.0, whereSnapshotTestingConfiguration.Recordwas introduced.🤖 Generated with Claude Code