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

assertTextEquals

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

assertTextEqualsSample

fun assertTextEqualsSample() {
    composeTestRule.setContent {
        // Explicitly merging descendants to demonstrate list semantics
        Row(Modifier.semantics(mergeDescendants = true) { testTag = "textRow" }) {
            Text("Hello")
            Text("World")
        }
    }
    // The merged text list is: ["Hello", "World"]
    // We provide all items exactly as they appear in the merged list.
    // Order does not matter.
    composeTestRule.onNodeWithTag("textRow").assertTextEquals("World", "Hello")
}

Last updated: