/chrisbanes-skills:compose-ui-testing-patternsfrom chrisbanes-skills
Provides patterns for Jetpack Compose UI testing: plain UI tests, screenshot tests, semantics assertions, fake image loading, keyboard input, focus, and interaction state.
Ships in chrisbanes-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Test the smallest UI contract that proves the behavior. Prefer plain state-driven UI tests with callbacks. Add integration only when lifecycle, navigation, DI, or platform behavior is the thing under test.
| What you need to prove | Test shape |
|---|---|
| Text, buttons, conditional content, loading/error states, click/input callbacks | Plain UI Compose test |
| Focus navigation or keyboard behavior | Compose test with key input |
| Visual layout, clipping, elevation, typography, image composition | Screenshot test |
| State holder updates UI correctly | State holder/unit test plus one wiring smoke test |
| Hover, pressed, focused, dragged interaction state | Plain UI test with MutableInteractionSource |
| Navigation, lifecycle, DI integration | Integration test |
| Critical flow that depends on the installed build or crosses an app, process, or OS boundary | Focused device smoke test or end-to-end test, outside this skill |
Keep an existing cheaper regression for the contract it already proves.
For a real permission flow, retain the createComposeRule denied-state
assertion and add a device check for the Android dialog and the result the
OS delivers to the app. For R8-sensitive startup, retain the debug integration
test and add startup on the optimized artifact. StateRestorationTester
proves the local Compose save-and-restore round trip. Use an installed test
when actual activity callbacks, process death, or OS restoration are part
of the required behavior.
Render the plain composable with controlled state and callbacks. Find nodes by
visible text or semantics. Use a tag when text is absent or ambiguous. Assert
enabled, selected, focused or toggled semantics directly, and use
assertDoesNotExist for absence. Capture callback arguments to prove wiring:
var selectedId: String? = null
composeTestRule.setContent {
ItemList(
items = listOf(ItemUi("movie-1", "Movie")),
onItemClick = { selectedId = it },
)
}
composeTestRule.onNodeWithText("Movie").performClick()
assertThat(selectedId).isEqualTo("movie-1")
Assert a plain captured value immediately after the action. Use runOnIdle
when the result depends on snapshot state, recomposition or queued work.
Use waitForIdle or a bounded waitUntil for a real asynchronous condition.
Leave clock auto-advance on unless testing a particular frame. With
mainClock.autoAdvance = false, advance to that frame once before its
assertions. Avoid Thread.sleep.
For hover, press, focus or drag interaction state, read the interaction-state procedure before writing or reviewing the test. It uses direct, injected interactions.
For keyboard or D-pad navigation, send keys and assert focused semantics. If the composable has no input surface that can change the state, identify the missing host or parent before proposing a test. For focus graphs, restoration and key handlers, see focus navigation.
Use screenshots for visual contracts such as spacing, clipping, typography, image composition or focus highlights. Fix data, time and animation progress. Use a local painter or bitmap when appearance matters. When testing which image was requested, use a fake loader and assert the requested model.
When a named preset or default intentionally changes, keep it in the test and update its baseline. Keep an explicit fixed value when that geometry is the contract. Preserve assertions and tolerances unless a separate change justifies altering them.
For a recording claim, report three checks separately: the actual comparison result, whether recording wrote the exact output path declared by the test, and the observed baseline diff. Quote the reported comparison status and name the literal output path even when absent. A passing comparison can leave the artifact and baseline untouched. For a findings-only review, stop at missing evidence. Keep tool-specific commands in the repository runbook.
What SKILL.md sets; muted values are Claude Code's defaults
23 skills in this plugin
/android-benchmark-comparisonUse when comparing physical Android benchmark configurations, investigating inconsistent rankings, or selecting an Android default from measured results. Do not use for code-level Compose performance diagnosis without a configuration comparison./changelogUse when updating or reviewing Unreleased changelog entries, reconciling a changelog against Git history and issue or PR evidence, or preparing changelog notes for a specified release./compose-animationsUse when writing or reviewing Jetpack Compose motion: visibility enter/exit, animating one property toward a target, color or size transitions, multiple properties from one state, switching composable content, or choosing between AnimatedVisibility, animate*AsState, updateTransition, rememberTransition, AnimatedContent, and Crossfade.npx claudepluginhub chrisbanes/skills --plugin chrisbanes-skillsOther plugins' skills for the same job