Turbine question. Is it expected that delays change the behaviour of tests?
Copy code
@Test
fun test() = runBlocking {
flow {
emit(1)
// This delay makes the test pass while it fails with 'Unconsumed events' otherwise
delay(1000)
}.test {
awaitItem()
}
}
j
jw
04/10/2024, 4:56 PM
The delay defers the close event and allows the test block to exit and cancel its collection. Without the delay you will have to consume the completion event.
m
mbonnin
04/10/2024, 4:59 PM
I see. This is a bit surprising. I would expect the completion event to be awaited forever/materialized
mbonnin
04/10/2024, 4:59 PM
Or is it to avoid hanging tests?
j
jw
04/10/2024, 5:01 PM
We used to force explicit cancelation, but the overwhelming majority of cases required explicit cancelation at the end of the block.
jw
04/10/2024, 5:02 PM
So now once the end of the block is reached we cancel collection