Tim Malseed
03/29/2023, 12:55 AMmainClock.autoAdvance = false
, advance by <500ms, perform the assertion, and then set mainClock.autoAdvance = true
. But, it feels like I’m creating a sort of brittle test. If that delay changes, the test will failAlex Vanyo
03/31/2023, 12:11 AMI think it’s because under test, there’s no real delay between loading and loginThere’s not necessarily any guarantee that in production you’ll ever see the “loading” state either if it goes from “loading” to “loaded” immediately You could sort of think of your entire UI as a giant
Flow.collectLatest
in the sense that intermediate states might not render, just the last one. If you have Compose code that requires composing with one state before recomposing with another, there’s probably something a bit weird going on.
Agreed that messing with time dispatching in tests is probably brittle, I’d probably aim towards something like
// kick off the request but don't let it finish
// assert loading state is correct
// manually allow request to finish and become loaded
// assert loaded state is correct
Tim Malseed
03/31/2023, 12:12 AM