nvim-neotest / neotest-jest

MIT License
116 stars 79 forks source link

"No tests found" in monorepo #121

Closed JamyGolden closed 2 months ago

JamyGolden commented 3 months ago

I'm working on a monorepo and so I understand things can be more complex to set up, however I can't seem to figure out how to debug why the plugin is not working correctly. The only info I get from neotest is No tests found", but I don't know why this is the case. Is it some of the paths I've set up in the config?

return {
  "nvim-neotest/neotest",
  dependencies = {
    "nvim-neotest/nvim-nio",
    "nvim-lua/plenary.nvim",
    "antoinemadec/FixCursorHold.nvim",
    "nvim-treesitter/nvim-treesitter",
    "haydenmeade/neotest-jest",
  },
  config = function()
    require('neotest').setup({
      adapters = {
        require("neotest-jest")({
          jestCommand = "yarn test:unit ",
          jestConfigFile = function()
            local file = vim.fn.expand('%:p')
            if string.find(file, "/web/", 1, true) then
              return string.match(file, "(.-/[^/]+/)") .. "jest.config.js"
            end

            return vim.fn.getcwd() .. "/jest.config.js"
          end,
          cwd = function()
            local file = vim.fn.expand('%:p')
            if string.find(file, "/web/", 1, true) then
              return string.match(file, "(.-/[^/]+/)")
            end

            return vim.fn.getcwd()
          end
        }),
      }
    })
  end
}

Are there any easy ways to debug the plugin to figure this out? I don't necessarily need help figuring this out, I can do that myself, but I do need to know how to check the properties used by neotest so I can see where the issue lies. Are there any articles or documentation about this? I can't find anything.

zakwarsame commented 2 months ago

Had this issue but it was treesitter not being able to parse tsx. You can check the logs at ~/.local/state/nvim/neotest.log I had to TSInstall tsx or TSInstall typescript in my case.

JamyGolden commented 2 months ago

Thanks @zakwarsame! The neotest.log file is helpful. I had tsx and typescript installed through TSInstall but I reinstalled them and neotest is initializing correctly now even though I still have issues.