neotest-jest icon indicating copy to clipboard operation
neotest-jest copied to clipboard

Another "No Tests Found" Error

Open vbfischer opened this issue 1 year ago • 3 comments

My configuration is based on LazyVim, having added support for Neotest by including the appropriate "extras" configuration.

{import = "lazyvim.plugins.extras.test.core" }

To ensure it wasn't an issue with my original project, I created a simple Next.js project here.

Additional configuration is specified in lua/plugins/test.lua with the following content:

return {
  {
    "haydenmeade/neotest-jest",
  },
  {
    "nvim-neotest/neotest",
    dependencies = { "haydenmeade/neotest-jest" },
    opts = function(_, opts)
      table.insert(
        opts.adapters,
        require("neotest-jest")({
          jestCommand = "npm test --",
          jestConfigFile = "jest.config.js",
          cwd = function()
            return vim.fn.getcwd()
          end,
        })
      )
    end,
  },
}

I have verified that package.json contains a script "test": "jest --watch".

I have verified that running the following on the command line works: npm run test.

I have verified that neotest-jest is apparently finding jest in devDependencies.

I have looked at what file_path parameter the function adapter.is_test_file is receiving, and it is NOT the file that "Run Nearest" was executed in.

I'm pretty sure Its something I'm doing wrong, but I've exhausted my current thoughts on what the issue might be... Any help would be appreciated, even if its tips on debugging.

vbfischer avatar Oct 23 '23 22:10 vbfischer

Answer from Here

added treesitter to dependencies:

    dependencies = {
      "nvim-treesitter/nvim-treesitter", -- this adding nvim-treesitter,
      "haydenmeade/neotest-jest",
    },


vbfischer avatar Oct 23 '23 22:10 vbfischer

This has been fixed in LazyVim in the meantime, so this can be closed...

folke avatar Oct 26 '23 17:10 folke

@folke Thanks for all your amazing work. Just as a data point, I've been trying to get neotest-jest working via :LazyExtras for a few hours now, and it was this thread, specifically adding the treesitter dependency as described above that finally resolved it. With the line there, it works, without it I get "No tests found". I'm on LazyVim 10.8.2, nvim v0.9.4, MacOS 14.2.1.

iryan2 avatar Dec 21 '23 10:12 iryan2