Skip to content

Commit e2af774

Browse files
runningcodeclaude
andcommitted
fix(snapshot): Use HtmlReportWriter recording mode for sentry images
SnapshotVerifier is verify-only and always compares against golden files. Replace it with HtmlReportWriter which has a recording mode (paparazzi.test.record=true) that copies images with predictable names to a configurable snapshot directory. Pass snapshotRootDirectory=sentryOutputDir to HtmlReportWriter so recorded images go to build/sentry-snapshots/images/ with names matching the sidecar JSONs (Paparazzi_Preview_Test_{screenshotId}). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d88d9ee commit e2af774

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

plugin-build/src/main/kotlin/io/sentry/android/gradle/snapshot/GenerateSnapshotTestsTask.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import androidx.compose.ui.Modifier
9999
import androidx.compose.ui.graphics.Color
100100
import androidx.compose.ui.unit.dp
101101
import app.cash.paparazzi.DeviceConfig
102+
import app.cash.paparazzi.HtmlReportWriter
102103
import app.cash.paparazzi.Paparazzi
103104
import app.cash.paparazzi.Snapshot
104105
import app.cash.paparazzi.SnapshotHandler
@@ -231,10 +232,13 @@ private object PaparazziPreviewRule {
231232
else -> SessionParams.RenderingMode.SHRINK
232233
},
233234
snapshotHandler = TestNameOverrideHandler(
234-
SnapshotVerifier(
235-
maxPercentDifference = tolerance,
236-
rootDirectory = sentryOutputDir,
237-
)
235+
when (System.getProperty("paparazzi.test.verify")?.toBoolean() == true) {
236+
true -> SnapshotVerifier(maxPercentDifference = tolerance)
237+
false -> HtmlReportWriter(
238+
maxPercentDifference = tolerance,
239+
snapshotRootDirectory = sentryOutputDir,
240+
)
241+
}
238242
),
239243
maxPercentDifference = tolerance,
240244
)

plugin-build/src/main/kotlin/io/sentry/android/gradle/snapshot/SentrySnapshotPlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SentrySnapshotPlugin : Plugin<Project> {
3737
"sentry.snapshot.output",
3838
sentrySnapshotRootDir.get().asFile.absolutePath,
3939
)
40+
testTask.systemProperty("paparazzi.test.record", "true")
4041
testTask.doFirst {
4142
val imagesDir = File(sentrySnapshotRootDir.get().asFile, "images")
4243
if (imagesDir.exists()) {

0 commit comments

Comments
 (0)