Compose Unstyled 2.0 is out! Check the official announcement blog ->
Function

assertContentDescriptionEquals

Asserts that the node's list of content descriptions contains exactly the given values and nothing else.

assertContentDescriptionEqualsSample

fun assertContentDescriptionEqualsSample() {
    composeTestRule.setContent {
        // Explicitly merging descendants to demonstrate list semantics
        Row(Modifier.semantics(mergeDescendants = true) { testTag = "iconRow" }) {
            Icon(ColorPainter(Color.Red), contentDescription = "Navigate Up")
            Icon(ColorPainter(Color.Yellow), contentDescription = "Go Home")
        }
    }
    // The merged content description list is: ["Navigate Up", "Go Home"]
    // We provide all items exactly as they appear in the merged list.
    // Order does not matter.
    composeTestRule
        .onNodeWithTag("iconRow")
        .assertContentDescriptionEquals("Go Home", "Navigate Up")
}

Last updated: