testing-with-espresso-interop

Coordinate Jetpack Compose UI tests with Espresso View interactions in Android Activities.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill testing-with-espresso-interop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-with-espresso-interop
Source: https://github.com/skydoves/android-testing-skills/tree/main/compose/interop/testing-with-espresso-interop
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill testing-with-espresso-interop

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves the coordination problem when Compose UI testing needs to interact with Android View and system-level UI elements using Espresso, such as Dialog windows and soft keyboard behavior.

Core Features & Use Cases

  • Compose ↔ Espresso synchronization bridge: Uses the built-in EspressoLink bridge so Compose idling resources are automatically recognized by Espresso without manual IdlingRegistry wiring.
  • Correct threading for Espresso calls: Ensures Espresso.onView(...) runs from the test thread and only after rule.waitForIdle() to prevent deadlocks or main-thread failures.
  • Hybrid Activity interaction patterns: Supports one-Activity, two-framework tests where Compose semantics and View hierarchy interactions must both be verified, including optional scoping via onRootWithViewInteraction for multiple ComposeView hosts.
  • Use cases: Dialog focus, IME (soft keyboard) tests, ComposeView embedded in View hierarchies, and focus interactions that cross the Compose/View boundary.

Quick Start

Use an Android Compose test rule with the host Activity, call rule.waitForIdle(), and then interact with Views using Espresso.onView(...) on the test thread for the target window or IME behavior.

Frequently Asked Questions about testing-with-espresso-interop

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

FAQPage Schema
How do I test Jetpack Compose UI with Espresso in the same Activity?

To test Jetpack Compose with Espresso in the same Activity, use createAndroidComposeRule with the host Activity, call rule.waitForIdle() to ensure Compose is ready, then execute Espresso.onView(...) interactions on the test thread to safely verify hybrid UIs.

Why does Espresso onView fail or deadlock during Compose UI testing?

Espresso onView fails during Compose UI testing when called from rule.runOnIdle or rule.runOnUiThread, or without waiting for Compose synchronization. Call rule.waitForIdle() first and run Espresso directly on the test thread to prevent deadlocks and main-thread failures.

Can I test soft keyboard visibility and Dialog window focus using Compose and Espresso together?

Yes, you can test soft keyboard visibility and Dialog window focus by leveraging the EspressoLink bridge. This synchronization bridge automatically recognizes Compose idling resources for Espresso, enabling reliable interactions across system-level UI elements and Compose boundaries.

Do I need to manually register IdlingResource for Compose and Espresso interoperability?

No, manual IdlingRegistry wiring is not needed for Compose and Espresso interoperability. The built-in EspressoLink bridge automatically recognizes Compose idling resources, synchronizing both frameworks so you can focus on View hierarchy and Compose semantics interactions.

What's the best way to test ComposeView embedded in an Android View hierarchy?

The best way to test ComposeView embedded in a View hierarchy is using the EspressoLink bridge with optional scoping via onRootWithViewInteraction. This approach correctly targets multiple ComposeView hosts, ensuring accurate synchronization across hybrid Compose and Android View interactions.