1.70.0
Experimental: Compose Preview screenshot tests for Compose Desktop
Note
Desktop preview support is experimental β feedback welcome in the issues.
Roborazzi can now generate preview screenshot tests for the Compose Desktop (JVM) target β no Robolectric involved (#897, #898, #899). Previews are scanned with ComposablePreviewScanner's android artifact, which is a pure-JVM jar, so multiplatform @Previews declared in commonMain are found on the desktop classpath too:
roborazzi {
@OptIn(ExperimentalRoborazziApi::class)
generateComposePreviewDesktopTests {
enable = true
packages = listOf("com.example")
}
}./gradlew recordRoborazziDesktop # compareRoborazziDesktop / verifyRoborazziDesktopWhy: Desktop-only Compose apps had no preview screenshot testing at all. Multiplatform projects could already capture their common previews with the Robolectric preview tests β the desktop tests are an alternative that runs roughly 4β6x faster (benchmark) by skipping the Android unit test environment (Robolectric) entirely. Robolectric remains the right choice when Android rendering fidelity matters: the two produce different images, so goldens are per-platform.
Feature parity with the Robolectric preview tests (#900, #902, #904): @Preview annotation options (widthDp/heightDp, fontScale, showBackground/backgroundColor, locale, uiMode dark bit), @PreviewParameter, @RoboComposePreviewOptions manual clock variations (one test per variation), annotation filtering with @RoboPreviewExclude/@RoboPreviewInclude, custom testers via testerQualifiedClassName with a composable-scope Capturer, and JUnit TestRule injection via testRuleFactory. device is not applicable on desktop.
If one module enables both the Robolectric and desktop generators, Roborazzi fails with a configuration error unless separateOutputDirs = true β the two would otherwise silently overwrite each other's goldens.
See the documentation and the sample project.
Huge thanks to @sergio-sastre for proposing this in #815 β and for ComposablePreviewScanner itself, whose pure-JVM design is what made it possible.
Documentation restructuring
The documentation was reorganized for easier navigation (#887β#895): UI tree dump, GIF and video, and GitHub Actions now have their own pages, and the remaining topics (build setup, how to use, Compose Multiplatform, preview support) were pruned of duplicated content. Documentation only β no code changes.
roborazzi-annotations is now multiplatform
roborazzi-annotations is published as a Kotlin Multiplatform library (Android, JVM, iOS) so the marker annotations and @RoboComposePreviewOptions can live in commonMain (#900). The Maven coordinate and every API signature are unchanged; only the packaging changed. If you consume it through Gradle (as testImplementation(...) / KMP source-set dependencies), nothing to do.
What's Changed
- Clarify how an AI agent proves UI fixes with the UI tree by @takahirom in #887
- Split UI tree dump docs into its own topic by @takahirom in #888
- Split GitHub Actions integration docs into its own topic by @takahirom in #889
- Split GIF and video capture docs into its own topic by @takahirom in #890
- Prune duplicated source paste and fix heading hierarchy in how_to_use docs by @takahirom in #891
- Reorder build setup docs into plugin, dependencies, tasks sequence by @takahirom in #892
- Fix heading hierarchy in multiplatform docs by @takahirom in #893
- Deduplicate annotationFilter explanation in preview docs by @takahirom in #894
- Prune stale FAQ entry and fix stale references in docs by @takahirom in #895
- Document Compose Multiplatform common preview support by @takahirom in #896
- Add proposal for Compose Desktop preview screenshot tests by @takahirom in #897
- Add roborazzi-compose-desktop-preview-scanner-support module by @takahirom in #898
- Add generateComposePreviewDesktopTests Gradle extension by @takahirom in #899
- Support RoboComposePreviewOptions manual clock in desktop preview tests by @takahirom in #900
- Document Compose Desktop preview screenshot test support by @takahirom in #901
- Address review findings for desktop preview test support by @takahirom in #902
- Apply
@Previewannotation options in desktop preview tests by @takahirom in #904 - Sync proposal capturer sample and delivery plan with shipped scope by @takahirom in #906
Full Changelog: 1.69.0...1.70.0