Skip to content

Instantly share code, notes, and snippets.

@LethalMaus
Created May 7, 2026 19:50
Show Gist options
  • Select an option

  • Save LethalMaus/3d1f8206803078c7e2d36d17fbcb264c to your computer and use it in GitHub Desktop.

Select an option

Save LethalMaus/3d1f8206803078c7e2d36d17fbcb264c to your computer and use it in GitHub Desktop.
Dejavu mapping repro test for article
package dev.repro.dejavu
import androidx.activity.ComponentActivity
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.test.ext.junit.runners.AndroidJUnit4
import dejavu.assertRecompositions
import dejavu.assertStable
import dejavu.createRecompositionTrackingRule
import dejavu.resetRecompositionCounts
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class ReproTest {
@get:Rule
val composeRule = createRecompositionTrackingRule<ComponentActivity>()
@Test
fun changingRetryState_recomposesStatusCard_only() {
var isRetrying by mutableStateOf(false)
composeRule.setContent {
ReproScreen(isRetrying = isRetrying)
}
composeRule.resetAndWait()
composeRule.runOnIdle {
isRetrying = true
}
composeRule.waitForIdle()
composeRule.onNodeWithTag(REPRO_STATUS_CARD_TAG).assertRecompositions(atLeast = 1)
composeRule.onNodeWithTag(REPRO_TOP_BAR_TAG).assertStable()
}
}
private fun ComposeTestRule.resetAndWait() {
waitForIdle()
resetRecompositionCounts()
waitForIdle()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment