add first class support for async testing without sleep
Here is how most of javascript does this. They basically allows done argument in the test and the test framework checks the argument and if it has 1 arg it considers it as async.
https://jestjs.io/docs/en/asynchronous
test('the data is peanut butter', done => {
function callback(data) {
expect(data).toBe('peanut butter');
done();
}
fetchData(callback);
});
Can we have something like this?
Async It should fetch data
call timer_start(5000, {t->Done()})
End
It does need to support default timeout and also allows us to specific custom timeouts which could be done by Async(10000) It should ...
This would make it easy to test async parts of vim-lsp.
Another easy option would be to support Wait()
It should work
let l:x = 0
call time_start(500, {t->l:x = 1})
Wait(1000)
Assert Equals(l:x, 1)
End
vim tests also seems to support WaitForAssert.
https://github.com/vim/vim/blob/5a4c3082d7ab51b3d448a91578479c96c1ab0ad3/src/testdir/test_popup.vim#L693
call WaitForAssert({-> assert_equal('', term_getline(buf, 1))})
We should have param for timeout/delay too.