Enabling Accessibility Checks logo

Enabling Accessibility Checks

Community
skydoves
enabling-accessibility-checks

Use this skill to enable Espresso's `AccessibilityValidator` against the Compose semantics tree via `enableAccessibilityChecks(...)` from `androidx.compose.ui:ui-test-accessibility` (for `ComposeUiTest`) or `androidx.compose.ui:ui-test-junit4-accessibility` (for `ComposeTestRule` / `AndroidComposeTestRule`). Covers the API surface, the auto-check after every UI-mutating action (`performMultiModalInput` is the lone exception), the manual `tryPerformAccessibilityChecks()` entry point, sharing the validator with Espresso via `AccessibilityChecks.enable()`, the API 34+ requirement, and the Robolectric inconclusive behavior (logs a `Log.w` warning and still installs the validator, but Robolectric does not faithfully drive accessibility services — b/332778271). Use when the developer asks "how do I enable a11y checks in a Compose test", "AccessibilityChecks.enable", "AccessibilityValidator throws on click", "robolectric a11y not supported", or "ComposeTestRule IllegalStateException".

Overview

Publisherskydoves
Repositoryandroid-testing-skills
Skill nameenabling-accessibility-checks
Stars
338
Forks
14
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by skydoves on GitHub. Read the source before you install it.

Installation

Install the Enabling Accessibility Checks AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/skydoves/android-testing-skills/tree/main/compose/debug/enabling-accessibility-checks
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/skydoves/android-testing-skills.git /tmp/android-testing-skills
mkdir -p .claude/skills
cp -r /tmp/android-testing-skills/compose/debug/enabling-accessibility-checks .claude/skills/enabling-accessibility-checks
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Enabling Accessibility Checks in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Enabling Accessibility Checks on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Enabling Accessibility Checks is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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 AccessibilityValidator between Espresso and Compose.
  • The developer's a11y check appears to do nothing on Robolectric (the Log.w warning 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 to androidDeviceTest and 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.

Prerequisites

  • Real Android device (or emulator) running API 34+ (Android U).
  • One of:
    • androidx.compose.ui:ui-test-accessibility on androidTestImplementation — extends ComposeUiTest. @RequiresApi(34) @ExperimentalTestApi. Needs @OptIn(ExperimentalTestApi::class).
    • androidx.compose.ui:ui-test-junit4-accessibility on androidTestImplementation — extends AndroidComposeTestRule and ComposeTestRule. @RequiresApi(34) only — NOT experimental.
  • The test class skeleton from ../../patterns/structuring-a-compose-test/SKILL.md.

Workflow

  • 1. Enable checks once per test (or in @Before). API for AndroidComposeTestRule:
kotlin
import androidx.compose.ui.test.junit4.accessibility.enableAccessibilityChecks
import com.google.android.apps.common.testing.accessibility.framework.integrations.espresso.AccessibilityValidator

@Before
fun before() {
    rule.enableAccessibilityChecks()      // default: AccessibilityValidator().setRunChecksFromRootView(true)
}

Default-validator signature, cited at compose/ui/ui-test-junit4-accessibility/src/androidMain/kotlin/androidx/compose/ui/test/junit4/accessibility/AndroidComposeTestRuleExt.android.kt:44-49:

kotlin
@RequiresApi(34)
public fun <R : TestRule, A : ComponentActivity> AndroidComposeTestRule<R, A>.enableAccessibilityChecks(
    accessibilityValidator: AccessibilityValidator =
        AccessibilityValidator().setRunChecksFromRootView(true),
)

For ComposeUiTest (e.g. inside runComposeUiTest { }), the equivalent lives in androidx.compose.ui.test.accessibility and requires @OptIn(ExperimentalTestApi::class):

kotlin
@OptIn(ExperimentalTestApi::class)
@Test
fun runs() = runAndroidComposeUiTest<ComponentActivity> {
    enableAccessibilityChecks()
    onNodeWithText("Submit").performClick()
}

Cited from compose/ui/ui-test-accessibility/samples/src/main/java/androidx/compose/ui/test/accessibility/samples/AccessibilityChecksSamples.kt:42-61.

  • 2. Configure stricter modes via the AccessibilityValidator itself. Pass a custom validator to flip the threshold from WARNING-only to ERROR.
kotlin
val validator = AccessibilityValidator().apply {
    setThrowExceptionFor(AccessibilityCheckResultType.ERROR)
}
rule.enableAccessibilityChecks(validator)

Cited from AccessibilityChecksSamples.kt:68-82.

  • 3. Auto-checks fire before every UI-mutating action. Cited at compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/Actions.kt:79, 160, 189, 236, 402, 451, 496, 535, 697, 780, 948 — tryPerformAccessibilityChecks() is invoked at the top of performClick, performScrollTo, performScrollToIndex/Key/Node, performTouchInput, performMouseInput, performKeyInput, performTrackpadInput, performRotaryScrollInput, performIndirectPointerInput, performFirstLinkClick, and the text-action family. performMultiModalInput does NOT auto-check (Actions.kt:582); the developer must call tryPerformAccessibilityChecks() explicitly. requestFocus() (Actions.kt:600-601) goes through performSemanticsAction and likewise does NOT auto-check — call tryPerformAccessibilityChecks() after focusing if accessibility coverage matters there.

  • 4. Run a check manually when needed (for performMultiModalInput, or to gate a phase).

kotlin
rule.onRoot().tryPerformAccessibilityChecks()

Cited from AccessibilityChecksSamples.kt:53.

  • 5. Share the validator with Espresso for hybrid Compose + View screens. AccessibilityChecks.enable() returns the same validator instance Espresso uses; pass it to Compose so both layers report against one configuration.
kotlin
import androidx.test.espresso.accessibility.AccessibilityChecks

@OptIn(ExperimentalTestApi::class)
@Test
fun hybrid() = runAndroidComposeUiTest<ComponentActivity> {
    val validator = AccessibilityChecks.enable()
    enableAccessibilityChecks(validator)
}

Cited from AccessibilityChecksSamples.kt:88-98.

  • 6. Disable checks when leaving an isolated phase.
kotlin
rule.disableAccessibilityChecks()

Cited at AndroidComposeTestRuleExt.android.kt:71-75.

  • 7. Use the ComposeTestRule overload only when the rule is concretely an AndroidComposeTestRule. Cited at compose/ui/ui-test-junit4-accessibility/src/androidMain/kotlin/androidx/compose/ui/test/junit4/accessibility/ComposeTestRuleExt.android.kt:38-49. Non-Android rules throw NotImplementedError:
text
Enabling accessibility checks is currently only supported for AndroidComposeTestRule.
If you have a custom ComposeTestRule implementation that wraps an AndroidComposeTestRule,
directly call enableAccessibilityChecks on the AndroidComposeTestRule instead

Patterns

Pattern: enabling on Robolectric — inconclusive results

kotlin
// WRONG (assertion is meaningless under Robolectric)
@Config(sdk = [34])
@RunWith(RobolectricTestRunner::class)
class MyA11yTest {
    @get:Rule val rule = createComposeRule(StandardTestDispatcher())

    @Test fun checks() {
        rule.enableAccessibilityChecks()                      // logs Log.w; validator IS installed
        rule.setContent { /* contrast violation */ }
        rule.onNodeWithTag("submit").performClick()           // may PASS, may FAIL — inconclusive
    }
}
// WRONG because: HasRobolectricFingerprint = (Build.FINGERPRINT.lowercase() == "robolectric")
// triggers a Log.w but the validator is STILL installed (ComposeUiTestExt.android.kt:50-61
// AND AndroidComposeTestRuleExt.android.kt:50-64). Robolectric does not faithfully drive
// the accessibility services, so any result is inconclusive. Tracking bug: b/332778271.
// Run accessibility checks ONLY on a real device API 34+ for trustworthy results.
kotlin
// RIGHT — move the test to androidDeviceTest and run on a real device API 34+
@MediumTest
@RunWith(AndroidJUnit4::class)
@SdkSuppress(minSdkVersion = 34)
class MyA11yTest {
    @get:Rule val rule = createComposeRule(StandardTestDispatcher())

    @Before fun before() { rule.enableAccessibilityChecks() }

    @Test fun submitPassesA11y() {
        rule.setContent { MyScreen() }
        rule.onNodeWithTag("submit").performClick()
    }
}

Pattern: performMultiModalInput skips the auto-check

kotlin
// WRONG
@Test
fun multiModal() {
    rule.enableAccessibilityChecks()
    rule.setContent { MyScreen() }
    rule.onNodeWithTag("canvas").performMultiModalInput {
        touch { down(center); up() }
        key  { pressKey(Key.Enter) }
    }
    // No a11y check ran for this action — Actions.kt:582 omits tryPerformAccessibilityChecks().
}
kotlin
// RIGHT
@Test
fun multiModal() {
    rule.enableAccessibilityChecks()
    rule.setContent { MyScreen() }
    rule.onNodeWithTag("canvas").performMultiModalInput { … }
    rule.onRoot().tryPerformAccessibilityChecks()             // explicit
}

Pattern: ComposeTestRule (non-Android) overload throws

kotlin
// WRONG
val rule: ComposeTestRule = MyCustomRuleThatWrapsAndroid()
rule.enableAccessibilityChecks()                              // throws NotImplementedError
// WRONG because: only AndroidComposeTestRule is supported. Cited at
// ComposeTestRuleExt.android.kt:38-49.
kotlin
// RIGHT — call on the underlying AndroidComposeTestRule
val rule = AndroidComposeTestRule(/* … */)
rule.enableAccessibilityChecks()

Pattern: shared validator with Espresso

kotlin
// RIGHT
@OptIn(ExperimentalTestApi::class)
@Test
fun shared() = runAndroidComposeUiTest<ComponentActivity> {
    val validator = AccessibilityChecks.enable().apply {
        setThrowExceptionFor(AccessibilityCheckResultType.ERROR)
    }
    enableAccessibilityChecks(validator)
    onNodeWithText("Submit").performClick()
}

Mandatory rules

  • MUST target real device API 34+ for any test that calls enableAccessibilityChecks. MUST NOT rely on the check producing meaningful results under Robolectric — Build.FINGERPRINT.lowercase() == "robolectric" triggers Log.w("...", "Accessibility checks are currently not supported by Robolectric") (ComposeUiTestExt.android.kt:50-53, AndroidComposeTestRuleExt.android.kt:50-56), and the validator is still installed but cannot rely on the accessibility services Robolectric does not faithfully emulate. Treat any pass under Robolectric as inconclusive. Tracking bug: b/332778271.
  • MUST prefer androidx.compose.ui:ui-test-junit4-accessibility (stable) when the rule entry point is used; MUST apply @OptIn(ExperimentalTestApi::class) when using androidx.compose.ui:ui-test-accessibility against ComposeUiTest.
  • MUST call tryPerformAccessibilityChecks() manually after performMultiModalInput { … } and after requestFocus() if the test wants validation for those actions — Actions.kt:582 omits the auto-check for performMultiModalInput, and requestFocus() (Actions.kt:600-601) routes through performSemanticsAction which likewise does not auto-check.
  • MUST NOT call enableAccessibilityChecks on a ComposeTestRule that is not also an AndroidComposeTestRule. The non-Android overload throws NotImplementedError (ComposeTestRuleExt.android.kt:38-49).
  • PREFERRED: raise the threshold to AccessibilityCheckResultType.ERROR via AccessibilityValidator().setThrowExceptionFor(...) so violations fail the test instead of merely logging.
  • PREFERRED: in hybrid Compose + Views suites, share one AccessibilityValidator via AccessibilityChecks.enable() and pass it to both Espresso and Compose. Cited at AccessibilityChecksSamples.kt:88-98.

Verification

  • The test runs on real device API 34+. @SdkSuppress(minSdkVersion = 34) is present if the module's minSdk is lower.
  • No Robolectric Log.w warning "Accessibility checks are currently not supported by Robolectric" appears in test output.
  • The relevant artifact is on androidTestImplementation: androidx.compose.ui:ui-test-junit4-accessibility (rule path) or androidx.compose.ui:ui-test-accessibility + @OptIn(ExperimentalTestApi::class) (ComposeUiTest path).
  • enableAccessibilityChecks(...) is called once per test (or in @Before); disableAccessibilityChecks() is called only when intentionally suppressing checks.
  • Any performMultiModalInput { … } site is followed by an explicit rule.onRoot().tryPerformAccessibilityChecks().
  • Hybrid Compose+View suites obtain the validator via AccessibilityChecks.enable() and pass it to enableAccessibilityChecks(validator).
  • No enableAccessibilityChecks call is made on a non-AndroidComposeTestRule instance.

References

  • enableAccessibilityChecks (rule path): compose/ui/ui-test-junit4-accessibility/src/androidMain/kotlin/androidx/compose/ui/test/junit4/accessibility/AndroidComposeTestRuleExt.android.kt:44-75
  • ComposeTestRule overload — NotImplementedError: compose/ui/ui-test-junit4-accessibility/src/androidMain/kotlin/androidx/compose/ui/test/junit4/accessibility/ComposeTestRuleExt.android.kt:38-66
  • enableAccessibilityChecks (ComposeUiTest path): compose/ui/ui-test-accessibility/src/androidMain/kotlin/androidx/compose/ui/test/accessibility/ComposeUiTestExt.android.kt:44-77
  • Robolectric inconclusive behavior (warns + still installs validator): ComposeUiTestExt.android.kt:50-61, AndroidComposeTestRuleExt.android.kt:50-64, b/332778271
  • Auto-check call sites in Actions.kt: compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/Actions.kt:79, 160, 189, 236, 402, 451, 496, 535, 582 (omitted), 697, 780, 948
  • Samples: compose/ui/ui-test-accessibility/samples/src/main/java/androidx/compose/ui/test/accessibility/samples/AccessibilityChecksSamples.kt:42-98
  • Espresso accessibility checks: https://developer.android.com/training/testing/espresso/accessibility-checking
  • Test for accessibility (Compose): https://developer.android.com/develop/ui/compose/accessibility/testing
  • Compose UI testing release notes: https://developer.android.com/jetpack/androidx/releases/compose-ui

Frequently asked questions

What does the Enabling Accessibility Checks AI skill do?

Use this skill to enable Espresso's `AccessibilityValidator` against the Compose semantics tree via `enableAccessibilityChecks(...)` from `androidx.compose.ui:ui-test-accessibility` (for `ComposeUiTest`) or `androidx.compose.ui:ui-test-junit4-accessibility` (for `ComposeTestRule` / `AndroidComposeTestRule`). Covers the API surface, the auto-check after every UI-mutating action (`performMultiModalInput` is the lone exception), the manual `tryPerformAccessibilityChecks()` entry point, sharing the validator with Espresso via `AccessibilityChecks.enable()`, the API 34+ requirement, and the Robo...

Why use Enabling Accessibility Checks on TypingMind?

Because you install it once and use it with any model. Enabling Accessibility Checks is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Enabling Accessibility Checks in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/skydoves/android-testing-skills/tree/main/compose/debug/enabling-accessibility-checks. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Enabling Accessibility Checks?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Enabling Accessibility Checks?

As many as you like. As long as a model supports skills, you can use Enabling Accessibility Checks with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Enabling Accessibility Checks AI skill free?

Yes. It is published on GitHub by skydoves under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇