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

Jest Config in Package JSON

Open jrock2004 opened this issue 1 year ago • 1 comments

I am using Lazy Neovim and setting up Neo test and for the config file, I have mine in package.json. How would I specify this? I tried commenting that out but I get no test found messages.

return {
  {
    'nvim-neotest/neotest',
    dependencies = {
      'haydenmeade/neotest-jest',
      'marilari88/neotest-vitest',
    },
    keys = {
      {
        '<leader>tl',
        function()
          require('neotest').run.run_last()
        end,
        desc = 'Run Last Test',
      },
      {
        '<leader>tL',
        function()
          require('neotest').run.run_last { strategy = 'dap' }
        end,
        desc = 'Debug Last Test',
      },
      {
        '<leader>tw',
        "<cmd>lua require('neotest').run.run({ jestCommand = 'jest --watch ' })<cr>",
        desc = 'Run Watch',
      },
    },
    opts = function(_, opts)
      table.insert(
        opts.adapters,
        require 'neotest-jest' {
          -- jestCommand = 'npm test --',
          jestCommand = 'yarn test',
          jestConfigFile = 'custom.jest.config.ts',
          env = { CI = true },
          cwd = function()
            return vim.fn.getcwd()
          end,
        }
      )
      table.insert(opts.adapters, require 'neotest-vitest')
    end,
  },
}

jrock2004 avatar Jul 10 '23 18:07 jrock2004

I was able to make it work just removing the jestConfigFile property.

dimas-cyriaco avatar Oct 23 '23 21:10 dimas-cyriaco