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 documentation on how to write tests for telescope.nvim #3049

Open
ColinKennedy opened this issue Apr 14, 2024 · 1 comment
Open

Add documentation on how to write tests for telescope.nvim #3049

ColinKennedy opened this issue Apr 14, 2024 · 1 comment
Labels
enhancement Enhancement to performance, inner workings or existent features

Comments

@ColinKennedy
Copy link

ColinKennedy commented Apr 14, 2024

Is your feature request related to a problem? Please describe.
I'm writing an extension and, despite checking every extension from the wiki, I couldn't find any that actually runs the their code via telescope calls. The best I saw was a couple plugins test their own internal logic and don't even attempt to call their code the way a user might.

Describe the solution you'd like
Be able to call a picker and query its contents in a unittest / integration test.

  it("shows up with 1 saved session", function()
    -- Some prologue code that could affect `assert.equal` later

    local picker = viewer.create()
    picker:find()
    assert.equal(1, picker.manager:num_results())  -- Some meaningful check
  end)

Describe alternatives you've considered
n/a

@ColinKennedy ColinKennedy added the enhancement Enhancement to performance, inner workings or existent features label Apr 14, 2024
@jamestrew
Copy link
Contributor

Probably the closest thing to this would be these tests https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/tests/automated/pickers/find_files_spec.lua

But even in our code base, its usage is very limited and hasn't been used for anything but some common operations for the find_files picker.
I tried writing some integration tests for another extension previously but I found it quite tricky (for my usecase). I would like to improve this aspect but I'm constrained for time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features
Projects
None yet
Development

No branches or pull requests

2 participants