Skip to content

Commit b08538d

Browse files
cameroncookeclaude
andcommitted
docs(snapshotting): Document snapshot env vars and align image names key
Add a reference table for the supported test-runner environment variables and clarify that the export and all-image-names modes are mutually exclusive. Rename the all-image-names env key to SNAPSHOTS_ALL_IMAGE_NAMES_FILE so it matches the SNAPSHOTS_ naming used by the other variables. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9296404 commit b08538d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,19 @@ xcodebuild test \
7777
-destination 'platform=iOS Simulator,name=iPhone 15 Pro'
7878
```
7979

80+
### Environment variables
81+
82+
SnapshotPreviews supports these test-runner environment variables:
83+
84+
| Variable | Description |
85+
| --- | --- |
86+
| `TEST_RUNNER_SNAPSHOTS_EXPORT_DIR` | Writes rendered snapshot PNGs and JSON sidecars to the given directory instead of attaching PNGs to the `.xcresult` bundle. |
87+
| `TEST_RUNNER_SNAPSHOTS_ALL_IMAGE_NAMES_FILE` | Writes all discovered logical `.png` image names to the given file, then returns without rendering previews. Used to support selective testing workflows. |
88+
89+
These modes are mutually exclusive. If `TEST_RUNNER_SNAPSHOTS_ALL_IMAGE_NAMES_FILE` is set, SnapshotPreviews writes image names only and does not render or export snapshot images.
90+
8091
> [!NOTE]
81-
> The `TEST_RUNNER_` prefix is how Xcode forwards an environment variable from `xcodebuild` into the test runner process. Inside the runner the variable is read as `SNAPSHOTS_EXPORT_DIR`.
92+
> The `TEST_RUNNER_` prefix is how Xcode forwards an environment variable from `xcodebuild` into the test runner process. Inside the runner, SnapshotPreviews reads the variable without that prefix.
8293
8394
For every rendered preview, two files are written:
8495

Sources/SnapshottingTests/AllSnapshotImageNamesWriter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

33
final class AllSnapshotImageNamesWriter {
4-
static let envKey = "SNAPSHOT_PREVIEWS_ALL_IMAGE_NAMES_FILE"
4+
static let envKey = "SNAPSHOTS_ALL_IMAGE_NAMES_FILE"
55

66
private let outputURL: URL
77

0 commit comments

Comments
 (0)