nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.26k stars 110 forks source link

[BUG] No tests found #90

Closed JElgar closed 2 years ago

JElgar commented 2 years ago

NeoVim Version

NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Describe the bug Getting No tests found when running lua require("neotest").run.run();

To Reproduce Please provide a minimal init.lua to reproduce which can be run as the following:

local packer_bootstrap = require('packer-setup').setup()

require('packer').startup(function(use)
    use 'wbthomason/packer.nvim'
      use({
          "nvim-neotest/neotest",
          requires = {
            "vim-test/vim-test",
            "nvim-lua/plenary.nvim",
            "nvim-treesitter/nvim-treesitter",
            "antoinemadec/FixCursorHold.nvim",
            "nvim-neotest/neotest-python",
          },
          config = function()
            require("neotest").setup({
              adapters = {
                  require("neotest-python")
              },
            })
          end,
        })

    if packer_bootstrap then
            require('packer').sync()
    end
end)

Packer setup is just:

local function setup()
    -- Bootstrap 
    local fn = vim.fn
    local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
    if fn.empty(fn.glob(install_path)) > 0 then
      packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
      vim.cmd [[packadd packer.nvim]]
    end

    local _, packer = pcall(require, "packer")

    -- Popup window for Packer 
    packer.init {
        display = {
            open_fn = function()
                return require("packer.util").float { border = "rounded" }
            end,
        },
    }

    return packer_bootstrap
end

return {
    setup = setup
}

Steps to reproduce the behavior: 1: Open a python file with tests, run: lua require("neotest").run.run();

  1. Get no tests found

Please provide example test files to reproduce.

test_thing():
    assert 1 == 2

Expected behavior Tests to be found

Logs There seems to be no neotest.log file in stdpath("data")

Additional context I've tried with various different adapters and files (larger python projects, jest and rust small and large) without any success

JElgar commented 2 years ago

So I found the logs in ~/.cache/nvim/neotest.log and turns out the issue was I didn't have any treesitter parsers installed. Following the setup on the treesitter page first sorted this out.

TLDR is I need to add this to my config: https://github.com/nvim-treesitter/nvim-treesitter#modules

matthiasbeyer commented 2 years ago

Hi, I have the same issues, but treesitter parsers are installed.

Log says:

ERROR | 2022-09-11T17:01:54Z+0200 | ...ages/start/vimplugin-neotest/lua/neotest/client/init.lua:265 | Couldn't find positions in path /home/REDACTED/src/cli.rs Failed to load parser: uv_dlopen: /nix/store/j4272ass70abzg944qj44iwr6xqbdp5m-vim-pack-dir/pack/myNeovimPackages/start/nvim-treesitter/parser/.: cannot read file data: Is a directory

(using nixos, hence the long path after uv_dlopen).

Can someone point me somewhere?

rcarriga commented 2 years ago

Can you open a separate issue and fill out the bug report? If you don't find the issue along the way then hopefully I'll be able to reproduce

johnpitchko commented 1 year ago

@JElgar I'm also having this issue but do not have a ~/.cache/nvim/neotest.log file. HOw do you enable logging for this? I will poke throught he config docs.

jfpedroza commented 1 year ago

The log file was moved to ~/.local/state/nvim at some point.

johnpitchko commented 1 year ago

@jfpedroza thanks, found it!