Hello, when testing async functions using the karma wrapper, what's a good way to prevent the test f...
r
Hello, when testing async functions using the karma wrapper, what's a good way to prevent the test from exiting before the async call has finished, since there's no await() and i can't have a suspend test function that can call join()?
Copy code
@Test
    fun example() {

        var i = 0

        fun asyncTask() = Promise<Boolean> { resolve, _ ->
            window.setTimeout({ i = 1; resolve(true) }, 100)
        }

        asyncTask().then {
            console.log("got result")
        } // there's no await so i can't prevent it continuing

        console.log("i want this to run after we've waited for the promise")

        assertEquals(i, 1)
    }
r
Thank you, I'll dig into those resources