nvim-neotest / neotest-jest

MIT License
116 stars 77 forks source link

Another "No Tests Found" Error #85

Open vbfischer opened 10 months ago

vbfischer commented 10 months ago

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 commented 10 months ago

Answer from Here

added treesitter to dependencies:

    dependencies = {
      "nvim-treesitter/nvim-treesitter", -- this adding nvim-treesitter,
      "haydenmeade/neotest-jest",
    },
folke commented 10 months ago

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

iryan2 commented 8 months ago

@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.