all repos — dot @ 13cc065ec014b86369dfe4ad60d1a43fa06fd251

Shell, editor and terminal configuration, and the tools that go with them

config/nvim/lua/plugins/testing.lua (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
return {
    {
        "nvim-neotest/neotest",
        dependencies = {
            "nvim-neotest/nvim-nio",
            "nvim-lua/plenary.nvim",
            "nvim-treesitter/nvim-treesitter",
            "nvim-neotest/neotest-jest",
            -- "marilari88/neotest-vitest",
        },
        cmd = { "Neotest" },
        keys = {
            { "<Leader>ta", function() require("neotest").run.run(vim.fn.getcwd()) end, desc = "Run all tests" },
            { "<Leader>tf", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run tests in file" },
            { "<Leader>tn", function() require("neotest").run.run() end, desc = "Run nearest test" },
            { "<Leader>to", function() require("neotest").output.open({ enter = true }) end, desc = "Show test output" },
            { "<Leader>tS", function() require("neotest").summary.toggle() end, desc = "Toggle test summary" },
        },
        config = function()
            require("neotest").setup({
                adapters = {
                    require("neotest-jest")({
                        jestCommand = "npm test --",
                        jestArguments = function(defaultArguments, context)
                            return defaultArguments
                        end,
                        -- jestConfigFile = "custom.jest.config.ts",
                        -- env = { CI = true },
                        cwd = function(path)
                            return vim.fn.getcwd()
                        end,
                        filter_dir = function(name, rel_path, root)
                            return name ~= "node_modules" and name ~= "dist" and name ~= "build"
                        end,
                    }),
                    -- require("neotest-vitest"),
                },
            })
        end,
    },
}