neovim-pluginlua-busted

Neovim and running tests with busted (not plenary.nvim) for async test fail


Hi I am currently trying to create a neotest-nodetest-test plugin for the native node test runner. I made a full copy of the neotest-jest-test plugin and am now trying to alter the bits and pieces for it to work.

However when i tried to run the test suite I found it only ran the first describe in the init_spec.lua file while there are many more describe functions defined. Then I stumbled upon this beauty of an article. https://mrcjkb.dev/posts/2023-06-06-luarocks-test.html and decided to go refactor the test suite. This actually seems to work in the sense that it now runs all describe function calls. However (yes many howevers in this post), what happened to me now was that I have issues using the nio package in neotest itself. It can't find the global 'it' function for running tests that are revered to in the 'nio' package. so I did some searching and discovered I don't need nio realy because busted is also capable of running async tests by using this kind of snippet:

it("test name", function()

async()

-- test logic comes here

done()

end)

see: https://lunarmodules.github.io/busted/#async-tests However (;-)) now I get the error: attempt to call global 'async' (a nil value)

Any Idea how to fix this issue?


Solution

  • Ok so I learned that busted doesn't have it's own async function. This is an omission in the documentation and needs to be updated https://github.com/lunarmodules/busted/issues/724

    the alternative is to use vim.wait