Hi. I wonder if there is a way to retrieve a seman...
# compose
Hi. I wonder if there is a way to retrieve a semantic object within a test and assert its values.
Say I have a composable with a text like this:
Copy code
val ItemKey = SemanticsPropertyKey<Item>("Item")
var SemanticsPropertyReceiver.item by ItemKey

data class Item(val id: Int, val name: String)

    modifier = Modifier.semantics {
        this.testTag = "test"
        this.item = Item(99, "TestXXX")
    text = "My text"
And now in my test, I want to retrieve the
object and assert its values
Copy code
composeTestRule.onNodeWithTag("test").assert(???, 99)
Anyone has a tip for how to do that?
There are other SemanticsMatchers for other things, and you can write your own assertions - just look at how the ones in the stdlib are implemented
Nice, that's easier than I thought for once ­čÖé Thanks for the help, I appreciate it
For reference if someone else is looking for this. you can create your own assert helper method. for above example it could look like this
Copy code
fun SemanticsNodeInteraction.assertItem(description: String, check: (Item) -> Boolean) {
    assert(SemanticsMatcher(description) {
and then i can write my tests like this
Copy code
composeTestRule.onNodeWithTag("test").assertItem("Checking id") {
    it.id == 99