Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add first class support for async testing without sleep #61

Open
prabirshrestha opened this issue Jan 1, 2020 · 2 comments
Open

add first class support for async testing without sleep #61

prabirshrestha opened this issue Jan 1, 2020 · 2 comments

Comments

@prabirshrestha
Copy link

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.

@prabirshrestha
Copy link
Author

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

@prabirshrestha
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant