Somewhat related (and this is very likely issue on...
# apollo-kotlin
j
Somewhat related (and this is very likely issue on my side but just in case anything jumps out)....I have a unit test in
commonTest
in KMM module using new
runTest
provided in Kotlinx Coroutines 1.6 to test some code that uses apollo...it runs fine for android, jvm but get issue when running for iOS .🧵
And select ios option here
as initial test it's doing following right now
Copy code
val people = repo.people.first()
assertTrue(people.isNotEmpty())
println(people)
testing the following flow that's in repository class
Copy code
val people = apolloClient.query(GetAllPeopleQuery()).watch().map {
    it.dataAssertNoErrors.allPeople.people.mapNotNull { it?.personFragment?.mapToModel() }
}
when I run for iOS I'm getting following due it seems to
first()
above never returning
Copy code
UncompletedCoroutinesError: After waiting for 60000 ms, the test coroutine is not completing, there were active child jobs
I suspect it might be some issue related to various dispatchers etc used but haven't been able to isolate it yet
If I replace
people
flow above with some dummy
flow { emit() }
for example it works fine
m
The apollo code always resumes coroutines on the main thread after a network call or database on iOS. Therefore it's important to have a main loop (as in dispatch_main) running
Apollo has its own
runTest
method that does this in
apollo-testing-support
Ultimately, this should all go away when switching to the new memory model
👍 1
j
pulling in the one from
apollo-testing-support
for now then....confirmed tests runs for iOS as well now https://github.com/joreilly/StarWars/pull/20
🎉 1