Is it possible to write a Compose UI test that cre...
# compose
z
Is it possible to write a Compose UI test that creates some composable UI, then removes it, and assert that the Composable UI isn’t there using the
AndroidComposeTestRule
assertions? Example in thread.
For example:
Copy code
val composeRule = createAndroidComposeTestRule(…)

@Test fun compositionDisappears() {
  // Adds a ComposeView to the view tree.
  setupComposeUi()

  composeRule.onNodeWithText("expected text").assertIsDisplayed()

  // Removes the ComposeView from the view tree entirely.
  tearDownComposeUi()

  // This line fails on alpha11 because no Compose views are found.
  composeRule.onNodeWithText("expected text").assertDoesNotExist()
}
This seems like a reasonable test to write to me. I would like to not have to check
Espresso.onView(isInstanceOf(ComposeView::class.java)).check(exists())
or whatever manually, since the fact that the view is torn down by removing the Compose view entirely vs just composing empty content is an implementation detail.
Am I missing some test API somewhere? If not, I have a bug ready to file.