compose-tests
Skill1.5k starsChanged 2 months agoMITView on GitHub
Use when writing Compose UI tests in stripe-android — covers composeRule setup, Robolectric annotations, node assertions, and test tag patterns
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about stripe/stripe-android
- stripe/stripe-ios“Port Stripe-iOS to Flutter”GitHub · Jan 31, 2019 · 64 reactions
- Adyen/adyen-web“Google Pay - Issue with Maestro - regression from #3539”GitHub · Nov 5, 2025 · 6 reactions
- facebook/facebook-android-sdk“Robolectric is incorrectly specified as non-test dependencies”GitHub · Oct 6, 2022 · 5 reactions
- thebergamo/react-native-fbsdk-next“Upgrade bouncycastle to org.bouncycastle:bcprov-jdk15to18:1.70”GitHub · Oct 5, 2022 · 3 reactions
- PhilipsHue/flutter_reactive_ble“Include our own proguard rules to simplify usages of our library ”GitHub · Nov 18, 2020 · 3 reactions
The biggest 5 of 6 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 6
Talked about on GitHub (6 times).
On GitHub · 6
- Jan 31, 2019Port Stripe-iOS to Flutter — stripe/stripe-ios64 reactions · 8 comments
- Nov 5, 2025Google Pay - Issue with Maestro - regression from #3539 — Adyen/adyen-web6 reactions · 8 comments
- Oct 6, 2022Robolectric is incorrectly specified as non-test dependencies — facebook/facebook-android-sdk5 reactions · 2 comments
- Oct 5, 2022Upgrade bouncycastle to org.bouncycastle:bcprov-jdk15to18:1.70 — thebergamo/react-native-fbsdk-next3 reactions · 6 comments
- Nov 18, 2020Include our own proguard rules to simplify usages of our library — PhilipsHue/flutter_reactive_ble3 reactions
1 more on GitHub
- Feb 10, 2023Opt certain crash reports not to affect crashlytics dashboard — firebase/firebase-android-sdk2 reactions · 1 comment
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- delegate-low-reasoning-workSkill
- fixing-flakesSkill
- network-testsSkill
- parameterized-testsSkill
- screenshot-testsSkill
- write-unit-testsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Every Compose test needs three rules and Robolectric:
- Very specific: line 34
Use the same runScenario pattern from write-unit-tests, wrapping composeRule.setContent:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Compose UI Tests
Patterns for testing Jetpack Compose UI in the Stripe Android SDK.
Test Class Setup
Every Compose test needs three rules and Robolectric:
@RunWith(RobolectricTestRunner::class)
internal class MyComposableTest {
@get:Rule
val composeRule = createComposeRule()
@get:Rule
val composeCleanupRule = createComposeCleanupRule()
@get:Rule
val coroutineTestRule = CoroutineTestRule(UnconfinedTestDispatcher())
}createComposeRule()— provides the Compose test harnesscreateComposeCleanupRule()— workaround for Robolectric resource leak (import fromcom.stripe.android.testing)CoroutineTestRule— controls coroutine dispatching in tests
runScenario for Compose Tests
Use the same runScenario pattern from write-unit-tests, wrapping composeRule.setContent:
@Test
fun `required fields are visible`() = runScenario {
page.country.assertIsDisplayed()
page.zipCode.assertIsDisplayed()
page.line1.assertDoesNotExist()
}
@Test
fun `input changes update state`() = runScenario(
addressCollectionMode = AddressCollectionMode.Full,
) {
page.zipCode.performTextReplacement("94100")
assertThat(formState?.postalCode?.value).isEqualTo("94100")
}
private fun runScenario(
addressCollectionMode: AddressCollectionMode = AddressCollectionMode.Automatic,
block: TestScenario.() -> Unit,
) {
composeRule.setContent {
MyComposableUI(addressCollectionMode = addressCollectionMode)
}
block(TestScenario(MyPage(composeRule)))
}
private data class TestScenario(val page: MyPage)Finding Nodes
| Finder | Use when |
onNodeWithTag(TAG) | Element has a test tag (preferred) |
onNodeWithContentDescription("desc") | Testing accessibility only — prefer test tags otherwise |
onAllNodesWithTag(TAG) | Multiple elements share a tag |
onNode(hasTestTag(TAG).and(hasText("x"))) | Combining matchers |
Assertions
| Assertion | Purpose |
assertIsDisplayed() | Element is visible |
assertExists() | Element exists (may not be visible) |
assertDoesNotExist() | Element not in hierarchy |
assertIsNotDisplayed() | Exists but not visible |
assertIsEnabled() / assertIsNotEnabled() | Enabled state |
assertTextContains("text") | Text field contains value |
assertContentDescriptionContains("desc") | Accessibility description |
assert(hasText("text")) | General matcher assertion |
Actions
| Action | Purpose |
performClick() | Tap element |
performTextReplacement("text") | Set text field value |
performScrollTo() | Scroll element into view |
Test Tags
Define tags as constants in production code, use Modifier.testTag():
// In production code:
internal const val SAVE_BUTTON_TEST_TAG = "save_button"
Box(modifier = Modifier.testTag(SAVE_BUTTON_TEST_TAG)) { ... }
// In test code:
composeRule.onNodeWithTag(SAVE_BUTTON_TEST_TAG).assertIsDisplayed()Waiting for Recomposition
// Wait for pending recompositions and then for async content
composeRule.waitUntilWithIdle(
conditionDescription = "node with tag $MY_TAG to appear",
) {
composeRule.onAllNodesWithTag(MY_TAG)
.fetchSemanticsNodes(atLeastOneRootRequired = false)
.isNotEmpty()
}Common Mistakes
- Missing
composeCleanupRule— causes resource leaks with Robolectric, flaky tests - Missing
@RunWith(RobolectricTestRunner::class)— Compose tests need Android framework - Using
onNodeWithTextfor dynamic content — prefer test tags for stability - Not calling
waitForIdle()after state changes — assertions may run before recomposition - Calling
waitUntildirectly for async UI — usewaitUntilWithIdlefor the standard idle synchronization and 5,000 ms timeout - Requiring a Compose root while polling — pass
atLeastOneRootRequired = falsetofetchSemanticsNodes
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

