Is it possible to always assert somehow maybe via Unit test or some flag that preview of composable is always rendering? (In our project there has been cases when people added some composition provider w/o fake values for preview or add some android related classed in compose which broke preview. I want to prevent these type of cases in PR itself)
👀 1
v
Vladimír Púpava
04/08/2025, 9:38 AM
You could generate automatic tests for all previews, we are zsing it for generating localization screenshots. But for case you are solving i would rather focus in preventing bade practices that resulted into this issue with detekt/ktlint/konsist rules.
a
Atul Gupta
04/08/2025, 9:40 AM
Ktlint will not work as that only does styling type of issues. In case of detekt there will be lots of false negatives. I am not sure about konsist.
But it seems that it is not possible as of now
v
Vladimír Púpava
04/08/2025, 9:50 AM
Not exactly ktlint has compose plugin that can guard some antipaterns. Afaik same exists for detekt in konsist you can simply write own rules
a
Atul Gupta
04/08/2025, 9:53 AM
But as far I know, it's not possible to make detekt rule for kind of complicated analysis. I am saying that from my knowledge of adding multiple rules in the detekt itself
Here compliation of preview is getting failed. If we can somehow compile all the preview in the PR itself then that would more straightforward approch
m
mattinger
04/08/2025, 2:57 PM
Maybe you could use @Preview based snapshot tests. Not 100% sure though. This would at least give you some visual feedback in a pull request if some preview wasn't rendering right