Skip to content

3.0.1

Choose a tag to compare

@TRazDev TRazDev released this 31 Aug 17:18
· 150 commits to main since this release

Added

  • Screenshot coverage from a single annotation. A @Preview composable marked @Mugshot now gets
    a golden image with no test file to write: the Gradle plugin generates a parameterised JUnit test
    that renders every annotated preview in the module, one case each so a failure names the preview
    that broke. Apply KSP alongside the plugin and the annotations, preview runtime and processor are
    supplied for you — the ksp block, the processor dependency and the namespace argument are gone.

  • Axis annotations that configure what gets rendered, and multiply when stacked: @MugshotShrink,
    @MugshotFullScreen, @MugshotDevices, @MugshotWear, @MugshotLightDark,
    @MugshotFontScales, @MugshotLocales and @MugshotMatrix. All of them target annotation
    classes as well as functions, so a team can bundle its house style behind one name. RTL layout is
    inferred from the locale.

  • mugshot-preview-junit, a new artifact holding the bridge from a generated preview case to a
    Mugshot rule. It is added to testImplementation by the plugin.

  • Lint warning MugshotPreviewArgumentsIgnored, reported when a @Mugshot function's @Preview
    sets configuration Mugshot does not read, so the IDE preview and the golden cannot silently
    diverge.

  • @Mugshot previews may take a @PreviewParameter. The processor cannot enumerate a
    PreviewParameterProvider at compile time, so generated code defers to parameterizedFrames in
    mugshot-preview-runtime, which expands the provider's values when the test runs. Each value
    becomes its own image, named by position (_0, _1, ...) rather than by the value, so golden
    filenames stay deterministic. The PreviewParametersNotSupported lint check is gone.

Fixed

  • A @Mugshot function carrying more than one @Preview generated one entry per @Preview, each
    with an identical snapshotName. No @Preview argument is read, so those entries were
    indistinguishable and their goldens collided. One entry is now generated per function.
  • The PreviewAnnotationNotFound lint check only looked at direct annotations while the processor
    resolved @Preview recursively. A @Mugshot function reaching @Preview through a custom
    multi-preview annotation generated correctly and then failed lint. The check now walks annotation
    trees the same way the processor does.

Changed

  • Breaking: mugshot-preview-runtime now exposes MugshotPreviewCase and
    MugshotPreviewConfig in place of MugshotPreviewData, and parameterizedFrames in place of
    parameterizedPreviews. The generated property is mugshotPreviewCases, not mugshotPreviews.
    Hand-written tests that iterated the old list can be deleted — the plugin generates one.

  • Breaking: @Preview arguments are not read. Configuration comes from the Mugshot annotations
    instead; see the lint warning above.

  • Breaking: the project is renamed from Paparazzi to Mugshot. There is no
    compatibility layer — every name below changes at once:

    • Maven group app.cash.paparazzi -> uk.co.fractalmotion.mugshot, and the
      artifacts paparazzi, paparazzi-gradle-plugin, paparazzi-annotations,
      paparazzi-preview-{runtime,processor,lints} gain the mugshot prefix.
    • Gradle plugin id app.cash.paparazzi -> uk.co.fractalmotion.mugshot.
    • Kotlin package app.cash.paparazzi.** -> uk.co.fractalmotion.mugshot.**.
    • Types Paparazzi -> Mugshot, PaparazziSdk -> MugshotSdk, and the
      @Paparazzi annotation -> @Mugshot.
    • Tasks recordPaparazzi*, verifyPaparazzi*, cleanRecordPaparazzi*,
      deletePaparazziSnapshots -> the same names with Mugshot.
    • System properties paparazzi.* -> mugshot.*, and Gradle properties
      app.cash.paparazzi.* -> uk.co.fractalmotion.mugshot.*.
    • Output directories build/reports/paparazzi -> build/reports/mugshot and
      build/paparazzi/failures -> build/mugshot/failures.

    Golden snapshot filenames embed the test's package name, so renaming your own
    test packages renames your goldens. Rename the files rather than re-recording
    if you want to prove the rebrand changed no pixels.

  • Breaking: snapshots are now stored as lossless WebP (.webp) instead of PNG. Re-record your
    goldens with ./gradlew recordMugshot<Variant>; existing .png goldens are not read.

Removed

  • Breaking: removed accessibility snapshot rendering and validation.
  • Breaking: removed animated snapshot support. Mugshot#gif and MugshotSdk#gif are gone,
    along with the snapshots/videos directory. Mugshot now records a single frame per snapshot.
    Use Mugshot#snapshot(view, offsetMillis) to capture a specific point in an animation, or
    InstantAnimationsRule to snapshot an animation's terminal state.
  • Breaking: SnapshotHandler#newFrameHandler no longer takes frameCount and fps. Custom
    SnapshotHandler implementations must drop those parameters.