What's the best practice for screenshot testing in...
# multiplatform
d
What's the best practice for screenshot testing in kmp/cmp? Using android with robo/paparazzi only, or are there tools for web/desktop/ios too?
g
For CMP, I’d go with Roborazzi for Android/Desktop/iOS where supported, and browser-based visual testing for Web/Wasm. Paparazzi is mainly Android/JVM-focused, so it’s not ideal if you want cross-platform screenshot coverage
d
oh, thanks... i thought there was something easier than having to create such a setup in each kmp project... maybe a library?
g
Yeah, that’s exactly what I was wondering too 😅 I was hoping there was a more plug-and-play library for CMP that could handle screenshot testing across platforms without having to set up everything for each project.
d
There's already #testballoon which is a great kmp test library... if there could be some kind of library based on it, it might be able to handle this nicely. The only minor detail is the way robolectric tests are set up a bit differently...
g
Yes of course
b
I used compose preview screenshot testing. I told codex to clone it and make it work for KMP.
d
I searched for that and fell on this one: github.com/sergio-sastre/ComposablePreviewScanner what do you think?
d
There is also this new thing from Google. I used it yesterday for an Android project and it works quite well. It's only Gradle configuration (plugin + deps). There is also an Android Studio plugin though I did not try it. https://developer.android.com/studio/preview/compose-screenshot-testing
d
That seems android only, no? See the Known issues section.
👍 1
d
@dave08 sure. But I read your question as open to a mix of single-plateform solutions. Was I wrong?
d
Well, what is that better than roborazzi and such?
d
Well, it is different in that you don't write tests but annotate
@Preview
composables with an additional annotation. And voilà... It is still experimental but it seems to me that this could be "easily" generalized to multiplatform in the future.
a
paparazzi also works great, since previews work in common, i just have a small one liner test which generates snapshots for anything annotated with preview. i gues its not that great with expect/actual composables, in my experience it was 0,5 %. for those who need more that could be an issue.