controlling-the-test-clock

Manually advance the MainTestClock to drive recomposition and animation cycles in Jetpack Compose UI tests.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill controlling-the-test-clock-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: controlling-the-test-clock
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/compose/synchronization/controlling-the-test-clock
Command: npx skills add https://github.com/trancee/MeshLink-template --skill controlling-the-test-clock-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves non-deterministic UI test failures by providing precise control over the Compose test clock, allowing developers to manually drive animations, recompositions, and coroutine execution.

Core Features & Use Cases

  • Deterministic Animation Testing: Manually advance the test clock frame-by-frame to verify animation states at specific intervals.
  • State Synchronization: Resolve race conditions in v2 Compose tests by explicitly draining queued tasks after state mutations.
  • Use Case: When an animation fails to trigger or a UI assertion fails due to a stale state read, use this skill to step the clock forward and ensure the Recomposer has processed all pending changes.

Quick Start

Use the controlling-the-test-clock skill to advance the main test clock by one frame and verify the updated UI state.

Frequently Asked Questions about controlling-the-test-clock

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manually advance the Jetpack Compose test clock frame by frame?

To manually advance the Jetpack Compose test clock frame by frame, you use a MainTestClock control mechanism to drive recomposition and animation cycles, ensuring deterministic animation validation in UI tests.

Why do my Jetpack Compose UI tests fail with a ComposeTimeoutException during animations?

Jetpack Compose UI tests fail with a ComposeTimeoutException due to non-deterministic timing and frame-delay issues; you can resolve this by explicitly managing the TestCoroutineScheduler to drain queued tasks.

How do I fix stale state reads and race conditions in Compose v2 UI tests?

Fix stale state reads and race conditions in Compose v2 UI tests by stepping the MainTestClock forward after state mutations to synchronize the Recomposer and process all pending changes.

Can I use the MainTestClock to verify animation states at specific intervals?

Yes, you can use the MainTestClock to verify animation states at specific intervals by manually driving the test clock forward, which allows precise frame-by-frame animation validation.

What are the limitations of manually controlling the test clock in Jetpack Compose?

Limitations of manually controlling the test clock in Jetpack Compose include the necessity to explicitly drain queued tasks after state mutations to avoid race conditions and ensure the Recomposer processes all pending changes.