Turbine question. Is it expected that delays chang...
# squarelibraries
m
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
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
I see. This is a bit surprising. I would expect the completion event to be awaited forever/materialized
Or is it to avoid hanging tests?
j
We used to force explicit cancelation, but the overwhelming majority of cases required explicit cancelation at the end of the block.
So now once the end of the block is reached we cancel collection
m
Alright, I'll let that soak in. Thanks for the pointers!