Skip to content

Add @RoboComposePreviewIgnore annotation#785

Open
takahirom wants to merge 6 commits into
mainfrom
tm/add-robocomposepreviewignore-annotation
Open

Add @RoboComposePreviewIgnore annotation#785
takahirom wants to merge 6 commits into
mainfrom
tm/add-robocomposepreviewignore-annotation

Conversation

@takahirom

@takahirom takahirom commented Jan 17, 2026

Copy link
Copy Markdown
Owner

What

Add @RoboComposePreviewIgnore annotation to exclude specific previews from screenshot tests.

Why

Closes #783. Users may want to exclude certain @Preview composables from generated screenshot tests without creating a custom tester class.

Usage

@RoboComposePreviewIgnore
@Preview
@Composable
fun MyPreviewToIgnore() {
  // This preview will be excluded from screenshot tests
}

Summary by CodeRabbit

  • New Features

    • Added an annotation to mark previews that should be excluded from screenshot generation; the preview scanner now respects this marker.
  • Tests

    • Added integration test to verify ignored previews are not recorded and excluded from generated outputs.
    • Added sample preview demonstrating the ignore annotation.
  • Chores

    • Updated test/build configuration so the annotation is available during preview generation.

@coderabbitai

coderabbitai Bot commented Jan 17, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new @RoboComposePreviewIgnore annotation, integrates it into the preview scanner to exclude annotated Compose previews from generated screenshot tests, updates sample previews and integration test projects, and adds tests to verify ignored previews are not recorded.

Changes

Cohort / File(s) Summary
Core Annotation
roborazzi-annotations/src/main/java/com/github/takahirom/roborazzi/annotations/RoboComposePreviewIgnore.kt
New annotation RoboComposePreviewIgnore to mark @Preview composables for exclusion.
Scanner Integration
roborazzi-compose-preview-scanner-support/src/main/java/com/github/takahirom/roborazzi/RoborazziPreviewScannerSupport.kt
Scanner pipeline extended to exclude previews annotated with @RoboComposePreviewIgnore before applying other filters.
Plugin Integration Tests
include-build/roborazzi-gradle-plugin/src/integrationTest/java/io/github/takahirom/roborazzi/PreviewGenerateTest.kt
Added test whenRecordRunIgnoredPreviewShouldNotBeRecorded() and helper checkNoIgnoredPreviewImages() to assert ignored previews are not recorded.
Integration Test Project (include-build)
include-build/roborazzi-gradle-plugin/src/integrationTest/projects/settings.gradle.kts, include-build/roborazzi-gradle-plugin/src/integrationTest/projects/.../Previews.kt
Added dependency substitution mapping for io.github.takahirom.roborazzi:roborazzi-annotations:roborazzi-annotations and added a PreviewIgnored() composable annotated with @RoboComposePreviewIgnore.
Sample Project
sample-generate-preview-tests/src/main/java/com/github/takahirom/preview/tests/Previews.kt
Added PreviewIgnored() composable annotated with @RoboComposePreviewIgnore demonstrating annotation usage in the sample app.

Sequence Diagram

sequenceDiagram
    participant Gradle as GradlePlugin
    participant Scanner as PreviewScanner
    participant Inspector as AnnotationInspector
    participant Filter as PreviewFilter
    participant Generator as TestGenerator

    Gradle->>Scanner: trigger scan for `@Preview` composables
    Scanner->>Inspector: inspect each preview's annotations
    Inspector-->>Scanner: mark previews annotated with RoboComposePreviewIgnore
    Scanner->>Filter: exclude annotated previews
    Filter->>Generator: supply filtered previews
    Generator->>Generator: generate screenshot tests for remaining previews
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • sergio-sastre

Poem

"I hop through code with whiskers bright,
I tag the previews out of sight,
The scanner skips my gentle mark,
Tests dance only in the light—
A carrot cheer for passing night 🥕"

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: adding a new @RoboComposePreviewIgnore annotation to exclude previews from screenshot tests.
Linked Issues check ✅ Passed The pull request fully addresses issue #783 by implementing a built-in @RoboComposePreviewIgnore annotation that allows users to exclude previews from generated screenshot tests.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the @RoboComposePreviewIgnore annotation feature: new annotation declaration, scanner integration, test coverage, and dependency configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/add-robocomposepreviewignore-annotation

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sergio-sastre sergio-sastre mentioned this pull request Apr 11, 2026
takahirom added a commit that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add excludeIfAnnotatedWithAnyOf property to roborazzi gradle plugin

1 participant