gaetan
02/09/2018, 1:31 PMelizarov
02/09/2018, 9:53 PMelizarov
02/09/2018, 9:54 PMgaetan
02/09/2018, 10:02 PMQUnit.test() can automatically handle the asynchronous resolution of a Promise on your behalf if you return a thenable Promise as the result of your callback function.
gaetan
02/09/2018, 10:07 PMgaetan
02/09/2018, 10:08 PMthen
function on the promise.ilya.gorbunov
02/10/2018, 5:16 AMgaetan
02/10/2018, 1:07 PM@Test
fun testPromise(): Promise<String> =
promise {
delay(1000)
assertTrue(true)
"OK"
}
The result captured by qunit as promise
is of type Unit and promise.then
is undefined which causes the problem.
When I do some plain javascript test (working):
QUnit.test( "a Promise-returning test", function( assert ) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
assert.ok(true);
resolve("result");
}, 1500);
});
});
promise
is a Promise object with then
defined as a function.gaetan
02/10/2018, 1:38 PMtestFn
should be ()->Any
to give back the result of the test function call to Qunit, allowing it to manage an potential Promise.elizarov
02/10/2018, 1:57 PMgaetan
02/10/2018, 1:58 PMelizarov
02/10/2018, 2:01 PM