Are there any tricks to testing `LaunchedEffect` a...
# compose
e
Are there any tricks to testing
LaunchedEffect
as far as
TestDispatcher
is concerned? I'm trying to
advanceTimeBy
past a
delay
in a
LaunchedEffect
but that isn't working because the dispatcher is a
AndroidUiDispatcher
(or
FlushCoroutineDispatcher
in desktop). As far as I can tell, the only way around this is to create a new context (
launch
,
withContext
, etc...) that uses the
TestDispatcher
. Is that correct, or am I missing something?
z
Are you using the
TestDispatcher
from the coroutines testing library?
e
Yes, I'm passing
UnconfinedTestDispatcher
to `runTest`:
e
e
I can try that, but
runComposeUiTest
isn't resolving for me on CfD 1.2.0 latest dev build.
MainTestClock
is resolving.
Although what I'm testing now relies on
ImageComposeScene
and those don't seem compatible.
z
I'm not sure what the right approach is, @Jelle Fresen [G] ?
e
@Igor Demin it looks like this wasn't pulled into CfD dev builds yet. Is that accurate?
I re-wrote all the tests I had for CfD for Android and they all work, so I'm assuming that CfD's test code doesn't have the latest from upstream? Or there are inconsistencies between the environments that needs addressing in CfD?
i
Yes, CfD still don’t have
runComposeUiTest
, because the latest rebase on Jetpack Compose was on 12 of April, but the feature was merged on 28 of April. The next rebase will be in about a month.
🙏 1
240 Views