Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

Compose animation tests

Writes Jetpack Compose animation tests that pause the clock and step frames, so they stop failing at random.

Claude's review

8/10 Exact recipe for deterministic Compose animation tests with clock pausing and UI thread pitfalls

We asked Claude the question you would ask: would I be glad I installed this? We only sell skills it rates 7 or higher.

In detail

Use this skill to write non-flaky Compose animation tests by setting mainClock.autoAdvance = false and stepping frames by hand with advanceTimeByFrame and advanceTimeBy(durationMillis). Explains why InfiniteAnimationPolicy cancels indeterminate animations the moment the test starts unless autoAdvance is disabled, why the first frame after a state toggle does not initialize playTime, and why state mutations during the paused-clock window must go through runOnUiThread instead of runOnIdle. If the user mentions "animation never finishes", "InfiniteAnimationPolicy CancellationException", "Crossfade test flaky", "indeterminate progress indicator", "Thread.sleep(500) waiting for animation", advanceTimeByFrame, advanceTimeBy, or autoAdvance, use this skill.

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: testing-animations-deterministically
description: Use this skill to write non-flaky Compose animation tests by setting mainClock.autoAdvance = false and stepping frames by hand with advanceTimeByFrame and advanceTimeBy(durationMillis). Explains why InfiniteAnimationPolicy cancels indeterminate animations the moment the test starts unless autoAdvance is disabled, why the first frame after a state toggle does not initialize playTime, and why state mutations during the paused-clock window must go through runOnUiThread instead of runOnIdle. If the user mentions "animation never finishes", "InfiniteAnimationPolicy CancellationException", "Crossfade test flaky", "indeterminate progress indicator", "Thread.sleep(500) waiting for animation", advanceTimeByFrame, advanceTimeBy, or autoAdvance, use this skill.
license: Apache-2.0. See LICENSE for complete terms.
metadata:
  author: Jaewoong Eum (skydoves)
  keywords:
  - jetpack-compose
  - ui-testing
  - animation-testing
  - main-test-clock
  - auto-advance
  - infinite-animation-policy
  - crossfade
  - flaky-animation-test
---

# Testing Animations Deterministically — `autoAdvance = false` Or Bust

A Compose animation test that does not pause the clock is by definition flaky. With `mainClock.autoAdvance = true` (the default), the framework's `InfiniteAnimationPolicy` throws `CancellationException` as soon as an indeterminate animation starts, and finite animations finish in a single auto-advanced burst with no observable intermediate state. This skill teaches the five-line recipe that fixes that, plus the runOnUiThread-vs-runOnIdle gotcha that bites every developer who tries it for the first time.

## When to use this skill

- The test asserts an intermediate frame of an animation (mid-fade alpha, mid-scroll offset, mid-Crossfade dispose).
- The composable contains an indeterminate animation (`LinearProgressIndicator()` with no progress argument, `rememberInfiniteTransition`, looping `withFrameMillis`).
- The developer reports `CancellationException("Infinite animations are disabled on tests")` and asks how to make it stop.
- The developer reaches for `Thread.sleep(500)` to "wait for the animation".
- The developer's animation test passes locally and fails on CI, or vice versa.
- The developer mentions `autoAdvance`, `advanceTimeByFrame`, `advanceTimeBy`, `Crossfade`, "flaky animation test", or `InfiniteAnimationPolicy`.

## When NOT to use this skill

- The animation is a side effect; the test only cares about the final state. Default `autoAdvance = true` is faster — see `../synchronizing-with-idle/SKILL.md`.
- The clock semantics themselves are unclear (frame model, rounding rules, v1 vs v2 dispatcher). Read `../controlling-the-test-clock/SKILL.md` first.
- The condition under test is not Compose state (a `Job.isCompleted`, a `Mockito.verify`). Use `waitUntil` or an `IdlingResource` from `../synchronizing-with-idle/SKILL.md`.
- The test uses screenshot comparison waiting on the RenderThread for ripple/elevation pixels. That is the one legitimate `Thread.sleep` site (skydoves hot take #7).

## Prerequisites

- `androidx.compose.ui:ui-test` and `androidx.compose.ui:ui-test-junit4` (or the JUnit-less `runComposeUiTest`).
...

From skydoves's repository, Apache-2.0 licence.

Related skills

  • Checked

    React Native tests

    Writes and fixes React Native component tests with Testing Library v13 and v14, using the right API for each.

    by callstackincubator 1.7k
    7/101 credit
  • Checked

    JUnit and Mockito tests

    Writes and fixes Java tests with JUnit, AssertJ and Mockito that are deterministic and keep failures visible.

    by github 42k
    8/101 credit
  • Checked

    Test code review

    Reviews new or changed tests in pytest, Jest, Go and more, so weak tests are caught before merge.

    by amElnagdy 1.3k
    8/101 credit
  • Checked

    Test scope decisions

    Decides which tests a change needs and how to judge their quality, for unit, integration and UI tests.

    by shinpr 725
    8/101 credit
  • Checked

    Playwright accessibility tests

    Writes Playwright and axe tests for WCAG, focus and ARIA, so accessibility bugs fail the build early.

    by fugazi 273
    7/101 credit
  • Checked

    Go table driven tests

    Writes Go tests with table cases, fakes, fuzzing, benchmarks and golden files that stay fast and reliable.

    by ericrisco 691
    8/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added