With Turbine we were trying to structure some test...
# squarelibraries
t
With Turbine we were trying to structure some tests that we could trigger a source flow passed in via the constructor using a MutableStateFlow. Ended up seeing some strange behavior when we then do a statein on the output flow and unsure if it is a coroutine bug or a Turbine bug. We simplified it down to the smallest test to prove the case
Copy code
@Test
    fun passesOnJavaFailsOnNative() = runBlocking {
        val failingFlow = MutableStateFlow(null).stateIn(GlobalScope, SharingStarted.Eagerly, "")
        failingFlow.test { assertNull(expectItem()) }
    }

    @Test
    fun passesOnNativeFailsOnJava() = runBlocking {
        val failingFlow = MutableStateFlow(null).stateIn(GlobalScope, SharingStarted.Eagerly, "")
        failingFlow.test { assertEquals("", expectItem()) }
    }
1
On the iOS test we see it not emit the initial value from the top MutableStateFlow (the null) and instead only have the stateIn default value, on JVM we see the inverse with it emitting the null