feat(snapshot): Add Compose preview snapshot testing plugin#1083
Draft
runningcode wants to merge 7 commits intomainfrom
Draft
feat(snapshot): Add Compose preview snapshot testing plugin#1083runningcode wants to merge 7 commits intomainfrom
runningcode wants to merge 7 commits intomainfrom
Conversation
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧Deps
🤖 This preview updates automatically when you update the PR. |
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Add Compose preview snapshot testing plugin ([#1083](https://github.com/getsentry/sentry-android-gradle-plugin/pull/1083))If none of the above apply, you can opt out of this check by adding |
c7d5b04 to
8988325
Compare
Add `io.sentry.android.snapshot` Gradle plugin that automatically generates Paparazzi snapshot tests for all @Preview composables. The plugin uses a two-phase approach: 1. Build time: ASM scans compiled .class files to discover @Preview methods (including custom multi-preview annotations) and writes a JSON config file 2. Test time: A generated parameterized JUnit test reads the config, invokes each composable via reflection, and captures snapshots through Paparazzi Usage: ```kotlin sentry { snapshots { enabled.set(true) } } ``` Then run `./gradlew recordPaparazziDebug` to record golden snapshots or `./gradlew verifyPaparazziDebug` to verify against them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the afterEvaluate block in SentryPlugin that auto-applied the snapshot plugin, and remove the SentryPluginExtension fallback in SentrySnapshotPlugin. The snapshot plugin is now fully standalone with its own sentrySnapshots extension. Also add IDE-specific files to .gitignore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
86380ad to
c887b44
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These properties were never read from the extension — the upload task gets appId from the Android variant and path from its own output dir. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was only used by the SentryPlugin.afterEvaluate block that auto-applied the snapshot plugin. Now that the plugin is standalone, users apply it explicitly and this flag serves no purpose. Co-Authored-By: Claude Opus 4.6 (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.
Summary
io.sentry.android.snapshotstandalone Gradle plugin that automatically generates Paparazzi snapshot tests for all@Previewcomposables@Previewmethods (including custom multi-preview annotations like@PreviewLightDark,@PreviewScreenSizes, etc.)@Previewannotations, container annotations (@Previews), and custom meta-annotationsArchitecture
Usage
Applied as a standalone plugin (requires Paparazzi):
plugins { id("io.sentry.android.snapshot") id("app.cash.paparazzi") } sentry { snapshots { // optional: // includePrivatePreviews.set(true) // variant.set("debug") } }🤖 Generated with Claude Code