-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement generateRobolectricPreviewTests prototype #416
Implement generateRobolectricPreviewTests prototype #416
Conversation
) | ||
project.dependencies.add( | ||
configurationName, | ||
"io.github.takahirom.roborazzi:roborazzi:$roborazziVersion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just as idea. One could provide default versions for roborazzi, robolectric & composablePreviewScaner, but allow to configure them via gradle plugin property
roborazzi {
automaticPreviewScreenshots {
...
roborazziComposeVersion = "1.20.0
robolectricVersion = "1.14.2"
composablePreviewScannerVersion = "0.1.2"
...
}
}
or
roborazzi {
automaticPreviewScreenshots {
...
libVersions {
roborazziCompose = "1.20.0
robolectric = "1.14.2"
composablePreviewScanner = "0.1.2"
}
...
}
}
That way it is more independent of external libraries, and convenient in cases were new versions break something that was previously working.
On the other hand, the main disadvantage is that if the public apis of any of those libraries changes the public apis, the generated code will not compile. However, One could throw a meaningful and verbose exception if the versions it is incompatible with are known.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've incorporated this suggestion.
} | ||
|
||
@GraphicsMode(GraphicsMode.Mode.NATIVE) | ||
@Config(sdk = [30]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this "sdk", which would be the equivalent to the @Preview(apiLevel = X)
, where the default apiLevel is -1.
Maybe not for the first version, but I believe it would make sense to create one test class for every api level:
val apiLevel = X // if X == -1, default to 34 for example
val previews = AndroidComposablePreviewScanner()
.filterPreviews(previewInfo -> info.apiLevel == X)
.getPreviews()
// WARNING: Do not create test if the list if empty, because ParameterizedTest with no parameters throw exceptions
if ( previews.size > 0 ){
// here the code to create a test for the previews for apilevel, with @Config(sdk = [apiLevel])
}
@Test | ||
fun snapshot() { | ||
val filePath = preview.methodName + ".png" | ||
captureRoboImage(filePath = filePath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea: For an upcoming version, one could create an annotation @RoborazziConfig
with all the desired Roborazzi configs (e.g. tolerance and accessibility) that would map accordingly to a RoborazziOptions.
https://github.com/sergio-sastre/ComposablePreviewScanner#roborazzi
The main thing is, that @RoborazziConfig
should be better in a different module, because it has to be used in the previews in "main", so added via implementation instead of testImplementation, for instance ->
implementation "io.github.takahirom.roborazzi:roborazzi-annotations"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also considering creating a module that might include a RoborazziOptionsMapper. It could be included in an upcoming version.
...gradle-plugin/src/main/java/io/github/takahirom/roborazzi/AutoPreviewScreenshotsExtension.kt
Outdated
Show resolved
Hide resolved
sample-auto-preview/build.gradle.kts
Outdated
|
||
roborazzi { | ||
automaticPreviewScreenshots { | ||
enabled = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether enabled
is necessary. I'd assume, that if automaticPreviewScreenshots
is added, it is enabled, and disabled if not.
What I'm not sure is what would happen with the generated test if automaticPreviewScreenshots
is removed? It should be deleted I'd expect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in my experience, Gradle plugins are likely to have an 'enable' property, which can be intuitive for users. It would be simpler without the 'enable' property, but this could lead to mistakes in the build logic or elsewhere. I don't have a strong opinion about this.
@Config(sdk = [30]) | ||
@Test | ||
fun snapshot() { | ||
val filePath = preview.methodName + ".png" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right now, the previewInfo
parameters like fontScale, locale, etc. are not set.
I've showcased how to set them here which is applied in this test :)
Still some important missing, like "device", and others like "wallpapers" are not currently possible in Robolectric as far as I know... likely worth documenting
dcf75df
to
d98a23f
Compare
|
||
private fun verifyMavenRepository(project: Project) { | ||
// Check if the jitpack repository is added. | ||
val hasJitpackRepo = project.repositories.any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
} | ||
|
||
roborazzi { | ||
generateRobolectricPreviewTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
…opertyOutputDirectory()
aa3d543
to
c2b9b27
Compare
I don't think it is needed for the first release, but there might be a feature request to adjust the tolerance of the diff. |
"Please refer to 'https://github.com/takahirom/roborazzi?tab=readme-ov-file#roborazzirecordfilepathstrategy' for more information." | ||
) | ||
} | ||
if (testTask.systemProperties["robolectric.pixelCopyRenderMode"] != "hardware") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that the property name is different before Robolectric 4.12.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than supporting older versions, maybe we should warn if using legacy versions? Are there typically reasons not to update robolectric if some new library you introduce uses it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I added a little comment for it.
a7984d0
.build() | ||
|
||
@GraphicsMode(GraphicsMode.Mode.NATIVE) | ||
@Config(sdk = [30]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my understanding is, that for the first version, we do not handle the preview properties, am I right?
I mean, locale, uiMode, fontscale, etc... they are indeed easy to support:
https://github.com/sergio-sastre/Android-screenshot-testing-playground/blob/master/lazycolumnscreen-previews/roborazzi/src/test/java/snapshot/testing/lazycolumn_previews/roborazzi/utils/RobolectricPreviewInfosApplier.kt
and then when creating the test, it has to be called before captureRoboImage
, for instance:
@GraphicsMode(NATIVE)
@Config(sdk = [34])
@Test
fun snapshot() {
RobolectricPreviewInfosApplier.applyFor(preview)
captureRoboImage(
filePath = filePath(AndroidPreviewScreenshotIdBuilder(preview).build())
) {
preview()
}
}
Other more complicated, like apiLevel, device etc. can be supported in next versions. Just my opinion.
@takahirom @yschimke
What do you think?
In that case, I'd also document which preview parameters are supported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergio-sastre @yschimke
Thank you for all your reviews!
I've created a new PR to handle the preview settings. Could you please take a look
https://github.com/takahirom/roborazzi/pull/427/files
…ic.pixelCopyRenderMode = hardware'
…w settings (#427) * Add roborazzi-compose-preview-scanner-support module to handle previews * Remove confusing option of generatedClassFQDN * Add comment * Fix integration tests * Add PreviewDarkMode preview * Make it more customizable * Fix space * Fix indent of generated code * Remove height of preview * Use Config(qualifiers) instead of setQualifiers to be able to setup by user * Rename customTestClassFQDN to customTestQualifiedClassName and add document * Add comments * Try ja-rJP * Add README section of Compose Preview Support * Use roborazziDefaultNamingStrategy() for Preview * Fix naming of parameterized tests * Divide the preview into two preview to fix too long file name * Revert unneeded change * Add The supported `@Preview` annotation options section * Change generateRobolectricPreviewTests to generateRobolectricComposePreviewTests * Rename generateRobolectricPreviewTests to generateRobolectricComposePreviewTests * Fix some warning and errors
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [io.github.takahirom.roborazzi](https://github.com/takahirom/roborazzi) | `1.21.0` -> `1.22.1` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [io.github.takahirom.roborazzi:roborazzi-junit-rule](https://github.com/takahirom/roborazzi) | `1.21.0` -> `1.22.1` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [io.github.takahirom.roborazzi:roborazzi-compose-desktop](https://github.com/takahirom/roborazzi) | `1.21.0` -> `1.22.1` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [io.github.takahirom.roborazzi:roborazzi-compose](https://github.com/takahirom/roborazzi) | `1.21.0` -> `1.22.1` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [io.github.takahirom.roborazzi:roborazzi](https://github.com/takahirom/roborazzi) | `1.21.0` -> `1.22.1` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>takahirom/roborazzi (io.github.takahirom.roborazzi)</summary> ### [`v1.22.1`](https://github.com/takahirom/roborazzi/releases/tag/1.22.1) [Compare Source](https://github.com/takahirom/roborazzi/compare/1.22.0...1.22.1) ### Bug fixes We've released Experimental Compose Preview Support in [1.22.0](https://github.com/takahirom/roborazzi/releases/tag/1.22.0). In this release, we are going to include a bug fix for it. The strategy of `generateComposePreviewRobolectricTests{}` is not to modify settings automatically, but to verify that the user settings are correct. This allows our settings to be the single source of truth. However, the assertion had some bugs, so I fixed them. #### What's Changed - \[Roborazzi Idea Plugin] Generate Roborazzi images via its IntelliJ Plugin by [@​eyedol](https://github.com/eyedol) in [takahirom/roborazzi#429 (We will address this topic in a future release) - \[Bug fixes] Fix assertions in Automated Test Generation for Experimental Compose Preview Support by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#432 **Full Changelog**: takahirom/roborazzi@1.22.0...1.22.1 ### [`v1.22.0`](https://github.com/takahirom/roborazzi/releases/tag/1.22.0) [Compare Source](https://github.com/takahirom/roborazzi/compare/1.21.0...1.22.0) ### Experimental Compose Preview Support 🚀 We're excited to announce the experimental release of [Compose Preview Support for Roborazzi](https://takahirom.github.io/roborazzi/preview-support.html), a powerful new feature that streamlines the process of generating screenshot tests for Jetpack Compose Previews. #### Key Features - **Automated Test Generation**: Automatically generate screenshot tests for Composable Previews using the [ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner) library - **Manual Integration Support**: For those who prefer more control, we've added helper functions to manually integrate Compose Preview screenshot tests. #### How to Use To enable Compose Preview screenshot test generation, add the following to your `build.gradle.kts`: ```kotlin roborazzi { generateComposePreviewRobolectricTests { enable = true } } ``` After configuration, run the `recordRoborazziDebug` task to generate screenshots using the newly created tests. #### Customization Options Customize your setup with options like: - Specifying package names to scan - Defining a custom test class - Configuring Robolectric settings #### Manual Integration For manual integration, add the following dependency: ```kotlin testImplementation("io.github.takahirom.roborazzi:roborazzi-compose-preview-scanner-support:[version]") ``` Then use the `ComposablePreview<AndroidPreviewInfo>.captureRoboImage()` function in your tests. Note that `ComposablePreview` is a class provided by the [ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner) library, which Roborazzi utilizes for this feature. This approach allows for more fine-grained control over the screenshot capture process for Compose Previews. #### Acknowledgements Special thanks to [@​yschimke](https://github.com/yschimke) for the initial proposal, and to [@​sergio-sastre](https://github.com/sergio-sastre) and [@​yschimke](https://github.com/yschimke) for their valuable design and code reviews. For more detailed information on setup and usage, please visit our [documentation](https://takahirom.github.io/roborazzi/preview-support.html). ### Enhanced Accessibility Text Capture Thanks to [@​lukas-mercari](https://github.com/lukas-mercari) 's contribution, we've improved accessibility text dumping for merged Compose elements. Both content descriptions and text are now captured, providing more comprehensive accessibility information in tests. ![image](https://github.com/user-attachments/assets/9b01a6b7-616b-46f8-bed8-cb2424eb9d17) #### What's Changed - \[roborazzi-idea-plugin] Fix: Icons are not shown in the new UI by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#421 - \[CI]Wait for main to succeed for compare ci by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#422 - \[CI] Remove main push trigger from compare ci by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#423 - \[CI] Add unit test for WebAssets class by [@​eyedol](https://github.com/eyedol) in [takahirom/roborazzi#412 - \[Sample]Update dependency androidx.compose.foundation:foundation to v1.6.8 by [@​renovate](https://github.com/renovate) in [takahirom/roborazzi#340 - \[Bug fixes] Dump both content description as well as text for the case when two elements are merged by [@​lukas-mercari](https://github.com/lukas-mercari) in [takahirom/roborazzi#430 - \[Improvement] Add roborazzi-compose-preview-scanner-support module to handle preview settings by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#427 - \[Feature] Implement generateRobolectricPreviewTests prototype by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#416 **Full Changelog**: takahirom/roborazzi@1.21.0...1.22.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/chrisbanes/haze). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjUuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [io.github.takahirom.roborazzi](https://github.com/takahirom/roborazzi) | plugin | minor | `1.21.0` -> `1.22.2` | | [io.github.takahirom.roborazzi:roborazzi-junit-rule](https://github.com/takahirom/roborazzi) | dependencies | minor | `1.21.0` -> `1.22.2` | | [io.github.takahirom.roborazzi:roborazzi-compose](https://github.com/takahirom/roborazzi) | dependencies | minor | `1.21.0` -> `1.22.2` | | [io.github.takahirom.roborazzi:roborazzi](https://github.com/takahirom/roborazzi) | dependencies | minor | `1.21.0` -> `1.22.2` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>takahirom/roborazzi (io.github.takahirom.roborazzi)</summary> ### [`v1.22.2`](https://github.com/takahirom/roborazzi/releases/tag/1.22.2) [Compare Source](https://github.com/takahirom/roborazzi/compare/1.22.1...1.22.2) ##### Notice [RobolectricPreviewTest and roborazzi.generateComposePreviewRobolectricTests.customTestQualifiedClassName](https://takahirom.github.io/roborazzi/preview-support.html#customizing-the-preview-screenshot-test) are used for customizing [Experimental Compose Preview Support](https://takahirom.github.io/roborazzi/preview-support.html). However, the name and class signature of RobolectricPreviewTest will be changed in a future release(not in 1.22.2) to support the Compose Multiplatform Preview Annotation. ##### Bug fixes We didn't have integration tests for [Experimental Compose Preview Support](https://takahirom.github.io/roborazzi/preview-support.html), so we added them. In KMP projects, we used to check only `testImplementation` (androidUnitTest.dependencies.implementation is used for KMP Android Unit tests), and the verification for generateComposePreviewRobolectricTests{} was failing. Therefore, we have added integration tests and fixed the behavior for KMP projects. ##### What's Changed - Refactor Roborazzi integration tests to support multiple modules by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#434 - Fix warning of RoborazziPreviewParameterizedTests by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#436 - Fix GenerateRobolectricComposePreviewTests to support KMP by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#435 **Full Changelog**: takahirom/roborazzi@1.22.1...1.22.2 ### [`v1.22.1`](https://github.com/takahirom/roborazzi/releases/tag/1.22.1) [Compare Source](https://github.com/takahirom/roborazzi/compare/1.22.0...1.22.1) ##### Bug fixes We've released Experimental Compose Preview Support in [1.22.0](https://github.com/takahirom/roborazzi/releases/tag/1.22.0). In this release, we are going to include a bug fix for it. The strategy of `generateComposePreviewRobolectricTests{}` is not to modify settings automatically, but to verify that the user settings are correct. This allows our settings to be the single source of truth. However, the assertion had some bugs, so I fixed them. ##### What's Changed - \[Roborazzi Idea Plugin] Generate Roborazzi images via its IntelliJ Plugin by [@​eyedol](https://github.com/eyedol) in [takahirom/roborazzi#429 (We will address this topic in a future release) - \[Bug fixes] Fix assertions in Automated Test Generation for Experimental Compose Preview Support by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#432 **Full Changelog**: takahirom/roborazzi@1.22.0...1.22.1 ### [`v1.22.0`](https://github.com/takahirom/roborazzi/releases/tag/1.22.0) [Compare Source](https://github.com/takahirom/roborazzi/compare/1.21.0...1.22.0) ##### Experimental Compose Preview Support 🚀 We're excited to announce the experimental release of [Compose Preview Support for Roborazzi](https://takahirom.github.io/roborazzi/preview-support.html), a powerful new feature that streamlines the process of generating screenshot tests for Jetpack Compose Previews. ##### Key Features - **Automated Test Generation**: Automatically generate screenshot tests for Composable Previews using the [ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner) library - **Manual Integration Support**: For those who prefer more control, we've added helper functions to manually integrate Compose Preview screenshot tests. ##### How to Use To enable Compose Preview screenshot test generation, add the following to your `build.gradle.kts`: ```kotlin roborazzi { generateComposePreviewRobolectricTests { enable = true } } ``` After configuration, run the `recordRoborazziDebug` task to generate screenshots using the newly created tests. ##### Customization Options Customize your setup with options like: - Specifying package names to scan - Defining a custom test class - Configuring Robolectric settings ##### Manual Integration For manual integration, add the following dependency: ```kotlin testImplementation("io.github.takahirom.roborazzi:roborazzi-compose-preview-scanner-support:[version]") ``` Then use the `ComposablePreview<AndroidPreviewInfo>.captureRoboImage()` function in your tests. Note that `ComposablePreview` is a class provided by the [ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner) library, which Roborazzi utilizes for this feature. This approach allows for more fine-grained control over the screenshot capture process for Compose Previews. ##### Acknowledgements Special thanks to [@​yschimke](https://github.com/yschimke) for the initial proposal, and to [@​sergio-sastre](https://github.com/sergio-sastre) and [@​yschimke](https://github.com/yschimke) for their valuable design and code reviews. For more detailed information on setup and usage, please visit our [documentation](https://takahirom.github.io/roborazzi/preview-support.html). ##### Enhanced Accessibility Text Capture Thanks to [@​lukas-mercari](https://github.com/lukas-mercari) 's contribution, we've improved accessibility text dumping for merged Compose elements. Both content descriptions and text are now captured, providing more comprehensive accessibility information in tests. ![image](https://github.com/user-attachments/assets/9b01a6b7-616b-46f8-bed8-cb2424eb9d17) ##### What's Changed - \[roborazzi-idea-plugin] Fix: Icons are not shown in the new UI by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#421 - \[CI]Wait for main to succeed for compare ci by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#422 - \[CI] Remove main push trigger from compare ci by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#423 - \[CI] Add unit test for WebAssets class by [@​eyedol](https://github.com/eyedol) in [takahirom/roborazzi#412 - \[Sample]Update dependency androidx.compose.foundation:foundation to v1.6.8 by [@​renovate](https://github.com/renovate) in [takahirom/roborazzi#340 - \[Bug fixes] Dump both content description as well as text for the case when two elements are merged by [@​lukas-mercari](https://github.com/lukas-mercari) in [takahirom/roborazzi#430 - \[Improvement] Add roborazzi-compose-preview-scanner-support module to handle preview settings by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#427 - \[Feature] Implement generateRobolectricPreviewTests prototype by [@​takahirom](https://github.com/takahirom) in [takahirom/roborazzi#416 **Full Changelog**: takahirom/roborazzi@1.21.0...1.22.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
#415