Skip to content

Instantly share code, notes, and snippets.

@oliverspryn
Created September 5, 2025 14:34
Show Gist options
  • Save oliverspryn/448fbf52d5389a63bf46a6bb08884720 to your computer and use it in GitHub Desktop.
Save oliverspryn/448fbf52d5389a63bf46a6bb08884720 to your computer and use it in GitHub Desktop.
A custom assertion to check the role of a composable
fun SemanticsNodeInteraction.assertHasRole(
role: Role
): SemanticsNodeInteraction = assert(
SemanticsMatcher("The element has a role of $role") {
it.config.getOrNull(SemanticsProperties.Role) == role
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment