I'm using jetpack compose and use this code to show my snackbar:
LaunchedEffect(true) {
viewModel.snackBar.collectLatest { message ->
scaffoldState.snackbarHostState.currentSnackbarData?.dismiss()
scaffoldState.snackbarHostState.showSnackbar(message = message)
}
}
normally, when I want to access to a compose element, I use testingTag in modifier. but the snackbar does not have any. so how can I test that my snack bars is shown with specific text?
I tried to use:
composeRule.onNodeWithText(SNACKBAR_MESSAGE).assertIsDisplayed()
but it can't find any node.