enabling-accessibility-checks
Installation
SKILL.md
Enabling Accessibility Checks — Espresso's AccessibilityValidator on the Compose Tree
The Compose accessibility test artifacts wire Espresso's AccessibilityValidator (from com.google.android.apps.common.testing.accessibility.framework.integrations.espresso) into the Compose action pipeline. Once enabled, every action that mutates the UI (performClick, performScrollTo*, performTextInput, …) runs the validator against the underlying View first. Two distinct artifacts cover two test entry points (ComposeUiTest and ComposeTestRule), with one stable and one experimental. Real device + API 34+ for meaningful results — on Robolectric the validator is still installed but a Log.w warning is emitted and any pass is inconclusive (Robolectric does not faithfully drive the accessibility services).
When to use this skill
- The developer is adding accessibility regression coverage to a Compose-only screen.
- A reviewer asks for an a11y test that fails the build when contrast / touch-target / label rules regress.
- The developer mentions "AccessibilityChecks.enable", "AccessibilityValidator", or "Compose accessibility validator".
- A hybrid Compose + Views screen needs a single shared
AccessibilityValidatorbetween Espresso and Compose. - The developer's a11y check appears to do nothing on Robolectric (the
Log.wwarning explains why).
When NOT to use this skill
- The check fails because of a bad finder, not an a11y violation. Use
../printing-the-semantics-tree/SKILL.md. - The test runs on Robolectric (host JVM). Cited limitation at
compose/ui/ui-test-accessibility/src/androidMain/kotlin/androidx/compose/ui/test/accessibility/ComposeUiTestExt.android.kt:50-53. Move the test toandroidDeviceTestand a real device API 34+ — see../../setup/setting-up-host-vs-device-tests/SKILL.md. - The test target API is below 34. The annotation
@RequiresApi(34)makes calls fail to compile on lower minSdk. Use@SdkSuppress(minSdkVersion = 34)on the test method and skip on older devices. - The user wants semantics test coverage (roles, content descriptions, click actions). Use
../../assertions/asserting-node-state-and-text/SKILL.md.