Start native apps faster with the Composables CLI ->
Function

assertTextContains

Asserts that the node's list of text values contains the given value.

assertTextContainsSample

@Sampled
fun assertTextContainsSample() {
    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"]

    // "Hello" is an exact match for one of the items in the list.
    composeTestRule.onNodeWithTag("textRow").assertTextContains("Hello")

    // "Hel" is a substring of an item in the list, and we explicitly enable substring matching.
    composeTestRule.onNodeWithTag("textRow").assertTextContains("Hel", substring = true)
}