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

vanshg

02/01/2023, 4:27 AM
heya 👋 . I'm writing a Composable that uses a
DisposableEffect
. What is the best way to test the invocation of this? Previously I've been using
Modifier.testTag(...)
to assert that a certain Composable is displayed, but this Modifier is not available on a
DisposableEffect
. To work around it, I tried also adding a
Spacer
that has a
testTag
set, but this doesn't seem to be working (the assertion that the spacer with the testTag is displayed is false). How can I test that a DisposableEffect has been invoked?
f

Filip Wiesner

02/01/2023, 8:52 AM
I don't have an answer to your question but for me it is similar question to "how to test that private method has been invoked". You shouldn't test the function itself but what the function does - how the state changes in result of invoking it.
3 Views