Is it possible to always assert somehow maybe via ...
# compose
a
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
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
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
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
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
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