composing-semantics-matchers

Combine multiple node constraints into single SemanticsMatcher predicates for Jetpack Compose UI testing.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill composing-semantics-matchers-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: composing-semantics-matchers
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/compose/finders/composing-semantics-matchers
Command: npx skills add https://github.com/trancee/MeshLink-template --skill composing-semantics-matchers-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves the issue of brittle, multi-step UI test assertions by enabling the creation of single, highly specific SemanticsMatcher predicates that combine multiple constraints into one query.

Core Features & Use Cases

  • Matcher Algebra: Combine multiple conditions using infix and, or, and operator not to create complex, readable queries.
  • Custom Semantics Support: Easily filter nodes based on custom SemanticsPropertyKeys using expectValue and keyIsDefined.
  • Hierarchical Filtering: Use predicates like hasAnyAncestor or hasAnyDescendant to locate elements based on their position in the UI tree without manual traversal.
  • Use Case: Instead of chaining multiple assert calls on a button, use a single matcher to verify that a node is both enabled and has specific text, ensuring the test fails with a clear, descriptive error message if any condition is unmet.

Quick Start

Use the composing-semantics-matchers skill to find a button that is both enabled and contains the text Submit by combining the hasText and isEnabled matchers.

Frequently Asked Questions about composing-semantics-matchers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I combine multiple conditions in a Jetpack Compose UI test query?

Combine multiple conditions in Jetpack Compose UI tests by using matcher algebra with infix and, or, and operator not to create a single declarative SemanticsMatcher predicate that filters nodes based on combined state and text constraints.

What is a SemanticsMatcher predicate used for in Jetpack Compose UI testing?

A SemanticsMatcher predicate is used to construct precise, declarative queries for Jetpack Compose UI testing. It filters UI elements based on state, actions, text, or hierarchical relationships, replacing brittle assertion chains with readable test code that provides descriptive failure messages.

How do I filter Compose nodes based on their position in the UI tree without manual traversal?

Filter Compose nodes based on their position in the UI tree by using hierarchical filtering predicates like hasAnyAncestor or hasAnyDescendant. This locates elements within the hierarchy declaratively, eliminating the need for manual tree traversal in your test code.

How do I test custom SemanticsPropertyKeys in Jetpack Compose UI tests?

Test custom SemanticsPropertyKeys in Jetpack Compose by using the expectValue and keyIsDefined functions. These allow you to easily filter nodes based on custom semantic properties within your declarative SemanticsMatcher queries.

Why do my chained Compose UI test assertions fail with unclear error messages?

Chained Compose UI test assertions often fail with unclear error messages because they rely on brittle, multi-step assert calls. Constructing a single, highly specific SemanticsMatcher predicate ensures the test fails with a clear, descriptive error if any condition is unmet.

Can I use matcher algebra to verify a Compose button is enabled and has specific text in one query?

Yes, you can verify a Compose button is enabled and has specific text in one query by combining the isEnabled and hasText matchers. This matcher algebra approach creates a single declarative query that ensures clear, descriptive test failures.