You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 74b9ab9
Browse filesBrowse the repository at this point in the historyBrowse files
feat(snapshots): Add snapshot group sidecar override (#271)
* feat(snapshots): Add snapshotGroup modifier to override sidecar group
Introduce a `.snapshotGroup(...)` view modifier that lets authors override the
top-level `group` field in the exported JSON sidecar. Accepts a custom string or
a `SnapshotGroup` strategy: `.default` keeps the generated group, `.custom` uses
a provided name, and `.module` groups by the preview container's module name.
Previously the sidecar `group` was always derived from the preview name, file
path, and module with no way to influence it. The override is plumbed from the
preference key through the rendering strategies and resolved during export, with
empty or whitespace-only custom values falling back to the generated group.
Exported filenames and manifest output are unaffected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(snapshots): Apply snapshotGroup modifier to demo previews
Exercise the new snapshotGroup modifier across the DemoModule card
previews by grouping them under "Card Views" and overriding OSVersionView
to the module group. Remove the unused snapshotDiffThreshold override from
RideShareButton now that grouping covers the demo coverage.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,7 +149,7 @@ Each `.json` sidecar contains the following fields:
149
149
| Field | Description |
150
150
| --- | --- |
151
151
| `display_name` | Snapshot name shown in Sentry. Generated from the preview name, file path, and module so exported filenames stay stable and unambiguous. |
152
-
| `group` | Grouping key Sentry uses to organize related snapshots. Generated from the preview name, file path, and module. |
152
+
| `group` | Grouping key Sentry uses to organize related snapshots. Generated from the preview name, file path, and module by default. |
153
153
| `diff_threshold` | Allowed visual difference for this snapshot. See details below. |
154
154
| `tags` | Optional key-value pairs used to filter and group snapshots in Sentry. |
155
155
| `context` | Supporting metadata such as test name, simulator info, orientation, color scheme, source line, preview attributes, and any custom context you add. These fields are surfaced on the snapshot detail page in Sentry's UI. |
@@ -158,6 +158,8 @@ SnapshotPreviews adds these `context` keys by default when values are available:
158
158
159
159
Use `.snapshotAdditionalContext(...)` to add custom fields to `context`. Custom context is shallow-merged into the generated context, so a custom key such as `"test_name"` replaces the generated value. Supported custom values are strings, numbers, booleans, and nested objects.
160
160
161
+
Use `.snapshotGroup(...)` to override the default `group` behaviour in the Sentry Snapshots UI. Pass a custom string such as `.snapshotGroup("Checkout")`, or a strategy: `.snapshotGroup(.module)`which groups by the preview container's module name.
162
+
161
163
Use the `.snapshotDiffThreshold(...)` view modifier from the `SnapshotPreferences` product to customize the allowed visual difference for a specific preview. For example, `.snapshotDiffThreshold(0.05)` allows up to a 5% difference for that snapshot.
@@ -218,6 +221,7 @@ Link the `SnapshotPreferences` product to your app target to customize individua
218
221
| `.snapshotExpansion(false)` | You want to preserve the visible scroll viewport instead of capturing all scroll content. | By default, scroll views are expanded so the snapshot includes their full content. Setting this to `false` keeps the scroll view at its normal visible height. |
219
222
| `.snapshotTags(["area": "checkout"])` | You want searchable labels on the exported snapshot. | Adds top-level `tags` to the JSON sidecar. Repeated tag modifiers merge, and later duplicate keys win. |
220
223
| `.snapshotAdditionalContext(["fixture": "loaded"])` | You want extra sidecar metadata for debugging or filtering. | Adds fields to the JSON sidecar `context` object. Repeated context modifiers merge, and later duplicate keys win. Custom keys override generated context keys. |
224
+
| `.snapshotGroup("Checkout")` | You want to control how related snapshots are grouped in Sentry. | Overrides the top-level `group` in the JSON sidecar. Also accepts `.snapshotGroup(.module)` to group by the preview container's module name, and `.snapshotGroup(.default)` to keep the generated group. Empty or whitespace-only custom strings fall back to the generated group. Does not change exported filenames or all-image-names manifest output. |
221
225
| `.snapshotDiffThreshold(0.05)` | A snapshot has small expected pixel differences. | Sets `diff_threshold` in the exported sidecar for this preview. `0.05` allows up to a 5% changed-pixel share before Sentry marks the image as changed. |
0 commit comments