What problem does it solve?
This Skill prevents Flow-based tests from hanging when asserting emissions from hot streams like StateFlow and SharedFlow by providing a one-at-a-time, cancellation-safe assertion workflow.
Core Features & Use Cases
- Assert ordered emissions without
toList(): Use flow.test { ... } / testIn(...) to await items, completion, or errors while ensuring no unconsumed events remain.
- Correctly handle hot vs cold Flow behavior: Avoid waiting for completion on hot flows and instead use
cancel() or cancelAndIgnoreRemainingEvents() to end the test deterministically.
- Support multi-flow assertions: Use
turbineScope and testIn to interleave assertions across multiple flows in the same test.
- Also verify non-Flow callbacks: Use the standalone
Turbine<T>() channel to capture listener/callback invocations with the same awaitItem()-style vocabulary.
Example use case
You have a ViewModel exposing uiState: StateFlow<UiState> and events: SharedFlow<Event> and you need to assert the initial seed value, the subsequent loading and success states, and a one-shot event in a single run without the test stalling.
Quick Start
Ask the AI to show how to write a runTest using vm.uiState.test { ... } that asserts the StateFlow seed, awaits the next two emissions, and finishes with cancelAndIgnoreRemainingEvents() to avoid hanging.