Hey folks, I'm trying to create some tests for com...
# compose
g
Hey folks, I'm trying to create some tests for composables where I inject a viewmodel, and the viewmodel holds StateFlows, I mock the viewmodel using mockito but I'm really struggling with how to get this working
Copy code
open class ImageListViewModel : ViewModel() {
	private val _isLoading = MutableStateFlow(false)
	val isLoading: StateFlow<Boolean>
		get() = _isLoading
}

@Mock
lateinit var viewModel: ImageListViewModel
private val isLoading = MutableStateFlow(false)

@Test
fun imageListScreen() {
	`when`(viewModel.isLoading).thenReturn(isLoading)
}
and then I get an error when running the test
Copy code
org.mockito.exceptions.misusing.MissingMethodInvocationException: 
when() requires an argument which has to be 'a method call on a mock'.
google 1