is there way to mock composable functions calls? F...
# compose
i
is there way to mock composable functions calls? For example mock
Copy code
isSystemInDarkTheme()
result
g
What is your use case? For UI tests?
i
Yep, i want to check behavior of elements depends on system day-night theme
Is it possible anyhow?
a
you could possibly just create a two new theme composables one that is always dark mode and one that is always light mode and use them for testing purposes.
Essentially writing two testing theme composables which read from your existing light and dark palettes. perhaps there is a better way
g
If you want to test your composable, do not rely on Ambient, instead explicitly pass param to you composable with display mode Ambient is really an anti pattern in most of the cases
👆 2
💯 1