Those functions are really syntax sugar, thanks for pointing towards them.
But they don’t make the clock advance, they just ensure that the code inside is run on Idle.
To make it work, this is needed:
@Test
fun test() = runTest {
composeTestRule.awaitIdle()
composeTestRule.runOnIdle {
assert(true)
}
}
It’s not that much, but it requires a bit of knowledge of how the Compose code was written.
For instance, you could do something like:
runTest {
composeTestRule.awaitIdle()
composeTestRule.runOnIdle {
//We are sure this is run on idle,
// but it's on the main thread, so you can't assert with `onNode***`
}
but, as you can see, you should advance the clock manually.
Something even cooler is:
fun test() = runTest { composeTestRule.waitUntilExactlyOneExists(hasText("screen")) composeTestRule.onNodeWithText("screen").performClick()
}
Anyway, this has helped me a lot. Thanks guys! 🫶