agentleFS
StripeKnown publisherstripe/stripe-android/.agents/skills/compose-tests/SKILL.md

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

Jan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentionsDec 2026: 0 mentions
Jan 2026Jul 2026Dec 2026
Mentions a month of the stripe/stripe-android repository that our weekly crawl found: only 6 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about stripe/stripe-android

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

1 more on GitHub

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
  1. Distinctive:

    Every Compose test needs three rules and Robolectric:

    line 12
  2. Very specific:

    Use the same runScenario pattern from write-unit-tests, wrapping composeRule.setContent:

    line 34

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 harness
  • createComposeCleanupRule() — workaround for Robolectric resource leak (import from com.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

FinderUse 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

AssertionPurpose
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

ActionPurpose
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 onNodeWithText for dynamic content — prefer test tags for stability
  • Not calling waitForIdle() after state changes — assertions may run before recomposition
  • Calling waitUntil directly for async UI — use waitUntilWithIdle for the standard idle synchronization and 5,000 ms timeout
  • Requiring a Compose root while polling — pass atLeastOneRootRequired = false to fetchSemanticsNodes

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.