marilari88 / neotest-vitest

Vitest adapter for Neovim Neotest plugin
92 stars 34 forks source link

No tests found #11

Closed h0adp0re closed 1 year ago

h0adp0re commented 2 years ago

Hello, I am getting this error when opening neotest summary window.

E5108: Error executing lua ~/.vim/bundle/plenary.nvim/lua/plenary/async/async.lua:18:
The coroutine failed with this message:
~/.vim/bundle/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message:
~/.vim/bundle/neotest/lua/neotest/adapters/init.lua:13: attempt to call field 'root' (a nil value)
stack traceback:
        [C]: in function 'error'
        ~/.vim/bundle/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'
        ~/.vim/bundle/plenary.nvim/lua/plenary/async/async.lua:45: in function 'step'
        ~/.vim/bundle/plenary.nvim/lua/plenary/async/async.lua:48: in function 'execute'
        ~/.vim/bundle/plenary.nvim/lua/plenary/async/async.lua:108: in function 'run'
        ~/.vim/bundle/neotest/lua/neotest/consumers/summary/init.lua:227: in function 'toggle'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

When attempting to run a single test, i get a message "No tests found".

marilari88 commented 2 years ago

Hi @h0adp0re, thanks for sharing the issue. I'm trying to reproduce it but In my projects all works fine. Are you receving it in a public repo? Can you write your configs? Plugin manager? OS?

h0adp0re commented 2 years ago

Sadly no, it's a private repo. I can try in a test project, haven't had time to do that yet.

My scenario is such that we have jest on master and vitest on next – where we are migrating our product to Vue 3. neotest-jest works on master, but neotest-vitest is not working on next.

I'm on macOS. I'm using Plug, I should probably test the plugin on a bare config. Although, I have forgotten how to do that.

I will first try to test it on a fresh project. When this produces no results, I'll try with a minimal config.

marilari88 commented 1 year ago

Ideally neotest-vitest should work in each condition, so We should understand what's wrong with your private repo. Please keep me informed of your attempts

h0adp0re commented 1 year ago

I don't know what happened or what was wrong, it started working. I just got done migrating from init.vim + Plug to init.lua + packer, maybe that had an impact?

marilari88 commented 1 year ago

Happy to know you solved your problem. Before closing the issue I'm going to investigate more on init.vim + Plug. Have other lua plugins worked on your previous config?

h0adp0re commented 1 year ago

Yes, every plugin worked normally on Plug. If you want to test with roughly what I had:

" init.vim

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath

source $HOME/.vim/vimrc
  " contains the following:
  " so $HOME/.vim/viml/plugins.vim  - contains all vim-plug stuff

lua require('plugins') " lua/plugins/init.lua
  " contains the following:
  " require("plugins.neotest")      - neotest config

One "issue" remains, though – when i have both neotest-vitest and neotest-jest active in the adapters table, neotest-vitest appears for a quick moment before neotest-jest takes over. But I suppose this anomaly is documented in this project.

h0adp0re commented 1 year ago

Ok, so the issue has reappeared now. Can't use neotest-vitest because of this error:

Error executing luv callback:
...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message: .../packer/start/neotest-vitest/lua/neotest-vitest/init
.lua:329: attempt to index field 'location' (a nil value)
stack traceback:
        [C]: in function 'error'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:45: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:44>

Not sure in what conditions the problem appears, will try to investigate.

Note that I am now using packer and everything is configured as per the instructions.

Edit: and neotest-vitest is the only adapter.

marilari88 commented 1 year ago

Hi @h0adp0re! sorry for the late reply. Not sure if It is the exact error you posted before. When does it occur? What's the Vitest version?

h0adp0re commented 1 year ago

Hey, sorry for the delay. I can't reproduce the problem once again. You can close the issue or keep it open if you want to investigate some more. I will update if and when I encounter the problem again.

marilari88 commented 1 year ago

Ok. In the meantime I have investigated and encountered this error in old versions of Vitest (0.18) due to the missing position field in the json test report. I have updated this adapter to handle this particular case. Please open a new problem if it occurs again

h0adp0re commented 1 year ago

Hey alright, that's good news. Our project uses Vitest 0.16.0 so maybe I'll look into updating that as well. Thanks for investigating!