feat(snapshotting): Add module-based preview filtering#260
Merged
cameroncooke merged 1 commit intoApr 29, 2026
Conversation
Allow consumers to include or exclude previews by module name via new `snapshotPreviewModules()` and `excludedSnapshotPreviewModules()` overrides on the `PreviewFilters` protocol, mirrored by `SNAPSHOT_PREVIEW_MODULES` and `EXCLUDED_SNAPSHOT_PREVIEW_MODULES` launch environment variables. Module names are matched exactly against the prefix of each preview type name (e.g. "MyModule" in "MyModule.MyView_Previews"), giving multi-module projects a coarse-grained filter without enumerating individual previews. Add a MultiModuleDemo example covering the new filters and unit tests for the module matching helpers.
NicoHinderling
approved these changes
Apr 28, 2026
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.
Add
snapshotPreviewModules()andexcludedSnapshotPreviewModules()overrides on thePreviewFiltersprotocol, plus matchingSNAPSHOT_PREVIEW_MODULES/EXCLUDED_SNAPSHOT_PREVIEW_MODULESlaunch environment variables, so multi-module projects can opt previews in or out by module without enumerating every preview type.Module names are matched exactly against the leading component of each preview type's fully-qualified name (e.g.
MyModuleinMyModule.MyView_Previews), giving a coarse-grained filter that mirrors how Swift namespaces previews. Inclusion and exclusion lists compose with the existing per-preview filters, and an empty list means "no filter" so existing consumers see no behavior change.A new
Examples/MultiModuleDemoproject exercises the filters across three SwiftUI modules and pairs withModuleFilterAssertionTeststo verify the matching helpers under the documented launch-env scenarios. The README is updated to describe the new APIs and env vars.Refs EME-1043