Background info: runTest
won't finish unless all the coroutines launched inside also finished. This is what I'd expect for most cases but it becomes problematic if I want something along the lines of:
val uiState = myFlow
.stateIn(viewModelScope, SharingStarted.Eagerly, UiStates.Empty)
The problem is that runTest
will hang and time out because of the job started by stateIn
/shareIn
which is kept active until viewModelScope
is canceled.