Hi
I'm in the process of creating my first neovim plugin and I'm running into some trouble testing it.
What I want to do:
describe('my test', function() it('asserts correctly', function() vim.api.nvim_feedkeys('isome text ', 't', false) local line = vim.api.nvim_get_current_line() assert('some text ', line) end) end)
What happens: line is blank. Probably due to the test finishing before neovim updates the line.
Things I've tried:
Using plenary
Problem: I can't figure out how to use asyc functionality
I don't understand the solution that was accepted by the issue creator.
Attempted fixes:
Using a function other than nvim_feedkeys (eg, nvim_buf_set_lines)
Problem: I want to test if my plugin reacts to autocmds (namely InsertCharPre with access to vim.v.char), and nvim_buf_set_lines does not allow me to do so.
Using vim.wait(0)
Problem: Adding the calls don't change anything
Mimicking how git-signs runs tests (using neovim)
Problem: I get attempt to index global 'vim' (a nil value) errors when I access vim inside of my plugin. I've tried looking at git-signs but can't see how they circumvent this problem.
Note: This dilemma only exists when running automated tests. Manually calling the function works as wanted, as long as I wrap nvim_get_current_line inside a vim.schedule() (however, wrapping it in vim.schedule does not help during testing)
Anything pointing me in the right direction would be appreciated.
Thanks
01-27-2022 11:07 PM
I've been writing a web app for about 6 months, and it has no integration tests. I have a few unit tests for some application logic, but no integration tests. How do I go about testing my application?
And when I say how, I don't really mean how. I know how to use QUnit and all of the Ember.js testing fixtures. I'm good at testing. My problem is that I don't know what to test. Do I test every button, every input and every URL? Do I test to make sure that things look OK, or just function? Should I test with a testing database, or a mock database?
I've been a Javascript developer for 2 years (and got about 4 years worth of experience in that time), but this is my first foray into integration testing an enterprise application. If anybody has any advice, I would really appreciate it. Feel free to post articles too. For the purpose of this thread, assume I've never written a test in my life. I want to start with a clean slate
03-15-2022 04:48 AM