Any ideas why this test fails <https://github.com/...
# coroutines
l
Any ideas why this test fails https://github.com/jshvarts/FlowChannels101/blob/master/app/src/test/java/com/example/coroutines/views/UserDetailViewModelTest.kt#L100 with
Wanted but not invoked observer.onChanged...no interactions with this mock
. Thanks in advance!
It's testing this block in view model
Copy code
viewModelScope.launch {
  val flow = userRepository.getUserRepos(login)
  _userRepos.value = flow
    .catch { _isUserReposError.value = true }
    .toList()
}
I think I see the issue—incorrectly declaring channel.
Hmm still no luck. Something to do with
toList()
and how the test is written
I ended up revising the view model and emitting items as they come in instead of converting to a list (similar to Observable/Flowable in RxJava).
userRepository.getUserRepos(login)
.catch { _isUserRepoError.value = true }
.collect { _userRepo.value = it }
đź‘Ť 1