'Write unit test for stateFlow

How can I write a unit test for Stateflow in the ViewModel

Stateflow in ViewModel:

private fun fetchLocation() {

    viewModelScope.launch {

       interactions.getLocation.invoke().collect {
            locationFlow.value = it
        }
    }
}

val getLocation: StateFlow<String?> = locationFlow


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source