The answer by @matpag is correct. But the same thing you can do with a more concise API
fun withRole(role: Role) = SemanticsMatcher.expectValue(SemanticsProperties.Role, role)
Here, SemanticsMatcher.expectValue
is the extension method on SemanticsMatcher
. There are more methods like keyIsDefined
and keyNotDefined