https://kotlinlang.org logo
#compose
Title
# compose
f

fengdai

06/14/2022, 11:57 AM
Hey guys. I have a question about Compose testing. My test has a
LaunchedEffect
which will change a state after a delay and trigger a recomposition. I want to wait for the end of the consequent recomposition and then do some assertions. How can I achieve the waiting?
waitForIdle
doesn’t work.
a

Albert Chang

06/14/2022, 1:26 PM
Have you tried
rule.mainClock.advanceTimeBy()
?
f

fengdai

06/14/2022, 1:41 PM
I've tried
waitUntil
to wait for the state changing. And I known the recomposition happens after that. If I use
advanceTimeBy
after the
waitUntil
. What's the appropriate time for it, so I can reach the end of the recomposition?
a

Albert Chang

06/14/2022, 2:01 PM
waitUntil
/
mainClock.advanceTimeUntil()
should also work if you know the condition.
8 Views