Who can help me with next: how can I test the emitted value from
MutableSharedFlow
which uses debounce?
Example: I’m using this flow to track the input text in textfield, debounce and distinct it, and if it passes I make some calculations.
But if in unit test I emit the value, it never enters the
collectLatest {}
lambda.
m
mkrussel
08/19/2022, 2:55 PM
I’ve not played with this, but I would guess using
TestCoroutineScheduler
that supports fake time, and I would recommend using the library Turbine to make it easier.
Basically advance time and then see if something is emitted.
v
Vsevolod Kaganovych
08/19/2022, 3:20 PM
I’m using the rule with
TestCoroutineScheduler
. Also, I don’t have the direct access to the flow reference, it just listens to the stream and when it collects, I do the next steps.