how do other people do tests that involve suspendi...
# javascript
n
how do other people do tests that involve suspending functions? in my karma test which i run in a
GlobalScope.launch
i see no log output at all if i use
promise
see all logs in a single line.. but the assertion seem to work.. somewhat
c
I had the same issue. I replaced Karma by Mocha and now I can see all the lines fine. No idea why Karma doesn't work though
n
mocha is not a option because then the app does not run.. and testing goes nowhere then either something about
window
not defined or such
r
You have to make sure the promise is returned by the test function, so its kind of tricky to do straight out of the box
if you write a test like:
Copy code
@Test
fun willOrganizeTestNicely() = GlobalScope.promise {
//test code here
}
the test will wait until the promise resolves before its done. When you don’t return a promise, you run the risk of the test “finishing” before the work is actually completed
I had to figure out all this nonsense in order to make a coroutines-compatible version of my library “testmints”, and I think it works pretty well. Could be some useful lessons in the source if you’re curious. https://github.com/robertfmurdock/testmints/tree/master/async AFAIK that works for both karma and mocha. And jasmine (I do some test running outside of the default tasks as well).